Reading the Apple documentation on the UITabBar states,
The most common use of a tab bar is to
implement a modal interface where
tapping an item changes the selection.
With my definition of Modal being:
A modal view is one that has to be
dismissed before you can do anything
else.
But that's not always the use case. I could be interacting with the content view of the UITabBar's first item/button, and that could allow me to reach another view.
OR, I could select another item/button from the UITabBar and reach yet another view.
So how is that considered Modal? (Or is my use case not Modal, and they are just saying, in general, its used Modally?)
I think "modal" here means different "modes".
Related
I have an issue with some of my views, here is a breif outline of my setup:
Tab Bar Controller
|
--View Controller 1
|
--View Controller 2
|
--View Controller 2
On a certain action, View Controller 1 will display a modal dialogue. Within this dialogue, if the user performs another action, then another modal dialogue is shown, using the first modal dialogue to present the view.
On the 2nd ModalDialog I have a UITextField, however when I attempt to type into the text field, nothing happens. Even though the keyboard is displayed and the textFieldDidBeginEditing method is called. I have setup the UITextFieldDelegate and the nessessary responders, but to no avail.
Does anyone know what would cause this issue?
Many Thanks
I've found that on a number of occasions with changing views and with popovers that text fields haven't focused correctly with symptoms like you describe. On these occasions I end up deferring the becomeFirstResponder call until the animation has finished or the view has loaded - for example in a view controllers viewDidAppear method.
Or, simply delay the call to becomeFirstResponder with an appropriate guestimate of the time it will take for the views to change / animate / etc. ie:
[textField performSelector:#selector(becomeFirstResponder)
withObject:nil
afterDelay:0.3];
I would try to 'chain' the modal dialogs from the view controller if that's possible.
The VC opens the 1st modal dialog
Your 1st modal dialog notifies the VC (using delegation probably).
(Maybe required) Close the 1st modal dialog
The VC opens the 2nd modal dialog
Happiness!
I'm not sure what you mean with "modal dialogue" -- I assume you mean either a modally presented view controller with a UIModalPresentationFormSheet modal presentation style or a UIPopoverController.
Here's my best guess: I'm pretty sure that your "modal dialogue" captures all user interactions (by default). So when pushing the first one, it captures all input focus. When pushing the second one, it's capture conflicts with the previous one and hence the keyboard will not work.
Anyways, both types of "modal dialogues" are not meant to be stacked. Even if it may work technically, I dislike like it form a interaction-design perspective. Instead of trying to fix the bug or work around it, try to rethink you modal dialogue. You may fit everything into a single one. For example by using a navigation controller inside that view, or by replacing the the view or by flipping it's contents... etc.
Hope this helps, Max
If I were you I would consider revising the navigational hierarchy. Modal dialogs are considered bad enough as it is, but incorporating a modal dialog within a modal dialog is user interface suicide. It causes confusion to the user and is very non-traditional. Is there any way you can use the first modal popup and simply exchange the content?
A side note: You mentioned setting up the view as being a UITextViewDelegate. Did you the view as the delegate for the textbox? Are you returning NO or FALSE from - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string?
I am making code for iPhone. My first screen has only one button with text Menu. When user will click on this button next screen is coming with multiple navigation bar.Each Navigation bar has their own Text information which are being selected after clicking on any Navigation bar.
How i should to design it for iPhone ? Please give me concept. Should i take multiple views ? If i have multiple views how will i hide and show on button click event ?
Thanks in advance.
You will have to adapt your user interface to comply to how Apple wants an app to work, look, and feel - or make your own custom viewcontrollers. Even then, you might not get the exact behavior you want.
My hottest tip is to look at similar apps on appstore and see how they are navigated.
I don't get a picture in my mind from your description, but it seems you want what is called "drill down". This is best done with tableViews.
You can't have multiple navigation controllers on the same "screen"; it doesn't work like that on the iPhone. Instead, what you have is one single Navigation controller, that controls the pushing of views. You decide which sub-view to push depending on which selection the user makes, and the Navigation controller handles the rest of the interaction with the user to let him or her navigate between the views.
Example structure:
Window-based app
+-MainWindow.xib
| +-First view with button
| +-UINavigationController
+-tableview1.xib
+-tableview2.xib
+-any more views you need.
Make the app delegate a <UINavigationControllerDelegate> and declare navCt *UINavigationController, and connect it in Interface Builder. You can then write a pushVC method, which takes as argument a UIViewController *vc. It does a [navCt pushViewController:vc animated:YES];
Connect the button to an IBAction, which then calls the method in the app delegate, [PushVC myVC], where myVC refers to any viewcontroller in your app, in this case table view 1.
In this table, on didSelectRow... event you can use the same method to push the sub-view table view 2.
I think this is minimum code if you are unsure about iPhone app design. Either way, I hope it gives some ideas.
You should read about UINavigationController, UITabBarController, UIViewController.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html
You almost always make one view pr. viewcontroller.
I'm building an iPhone app and I'm sort of confused about which approach should I choose for views and controllers.
I would like to have a tabbar at the bottom with three options. I would also like to have a main view displayed when the app shows (along with the tabbar) but I don't want this view to be part of the tabbar options.
So, when the app begins, the tabbar has no option selected but the main view displayed. When a tabbar options is selected, in its top bar it should display a back button to the main view. When the back button is pressed, the main view display again with no tabbar option selected.
Which approach should I choose?
Hope it makes sense.
Thanks.
I understand what you're trying to do, but you shouldn't do that. I don't like that design at all. You should have one navigation controller for each tab.
You should probably read Apple's Human Interface Guidelines as it's possible they would reject your App if they thought such an implementation with a TabBarController was confusing.
As an alternative, you could possibly have the "main view" as you call it accessible with a button in the Navigation bar at the top and then add that to all three tabs. Not necessarily a better design but you probably wouldn't be breaking the guidelines.
A better alternative might be to use a UIToolBar at the bottom instead of the Tab bar which has the three buttons spawning your views modally which can then be dismissed as you suggest.
Remember though, your App's users have built up a knowledge of how App's are generally supposed to navigate, feel and control so you should think carefully before deciding to go against that.
Firstly, I think you should reconsider giving your Main View it's own tab. That way it's a no-brainer for the user to return to that screen. BUT, if you STILL don't like that idea, read on...
The UITabBarController has the unfortunate side effect of not being able to be removed once created (even if you delay it's creation by instantiating it programmatically).
SO...
Option 1: Make your MainView a modalPresentation sub-view, displaying it ON TOP of one of the views in your tab bar (hiding the tabs until you're ready to show them again).
Option 2: Give a subview of your first tab a...
mySubViewController.hidesBottomBarWhenPushed=YES;
This will make the UITabBarController disappear temporarily (just on that view, until you're ready to show the tabs again).
Both options seem kinda messy to me, but they are possible. Depends on how well you execute them, I suppose.
Hope this helps!
You could add the main view as another tab.
OR
You present the main view modally when the app starts over the tab bar views.
The first option would be used more if the view holds the same kind of content as the tabs, for example if the app was an online store, the tabs would be Categories, Search and Recently Added, with what you call the "main view" being the Home page (showing offers or something). (So all the views/tabs would be showing products on the store)
The second option would be more if the content of the main view is different to the tabs.
Keeping with the online store example, if the tabs were Categories, Search and Recently added and what you call the "main view" being a login/logout screen. (so the tabs would be showing products, but the modal view ("main view") being more admin related, and it's main purpose not being to display products.
hi
I'm new to objective-c
i need to create a view, that has four buttons at the bottom, and a view above them that changes according to which button you press.
now i've been reading a bit of tutorials, and i still have difficulties understanding the different nib files.
But i'm wondering.
i have 'tab bar controllers' in the controllers sections in the library and i have 'tab bar' in the 'windows views and bars' section.
now according to what i've read, and understood...
i have to use tab bar controller and add it to the 'Mainwindow.xib' and implement and link the stuff.
But can't i just add a tab bar in my 'appnameViewController.xib', and manage the tabbar items' click to change views. without relying on the tb controller??
If you want tab bar functionality you really should use UITabBarController. While it is possible to repsond to the the taps on the tap bar and switching views by yourself it is not recommended. Some reasons why:
You would just duplicate code that UITabBarController already does.
UITabBarController will handle things like unloading views not on screen when a memory warning is received.
If you end up changing the amount of tabs in your application it would still just work with a UITabBarController.
There are probably many more better reasons but since an iOS device have limited memory the memory aspect alone would make it a no brainer.
You need to familiarize yourself with the Model-View-Controller design pattern, which Cocoa follows religiously. Controllers deal with the application-specific logic the user interface (the views) provides.
For example, a button is a view but a controller handles the button's click (and setting its enabled/disabled state, etc.) depending on application logic.
I think you are confusing the tab bar view with it's view controller (UITabBarController).
Apple's documentation explains it well:
http://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/TabBarControllers/TabBarControllers.html
I have a navigation app that has many screens the user navigates to. A handful of views manages these screens dynamically. What I want to try to do is add a button that will always show up on every screen the user views. I need to do this so that the user is always able to preform the action associated with the button regardless of where they are in the app.
Is it possible to achieve this by adding this button only once and having it passed between views like my navigation bar is? Or do I just have to man up and add this button and its functionality to every single view file I have?
Thanks
I would say it probably depends on what the button does. If the button is generic to all views, meaning it affects all views the same exact way so no customization for a given view is needed, then a way to do this would be to include the function in the App Delegate or as a subclass to your Navigation controller.
You can then use the rightBarButtonItem to always show the same button and just access that method. You would just have to add code for the rightBarButtonItem in each viewDidLoad (but they'd all be the same).
I did something similar to this with an "Upgrade" button on one project. Since all the button does is launch the AppStore to the paid version, it's independent of all views and I can place it anywhere.
You can put the button on the navigation bar if you want. Alternately, the more generic way to do this would be to split your single view into two views. One is small and only contains your button but always stays on the screen. The second is your workspace and you swap in and out the views that are displaying the current content. You'll note that this is the way the navigation controls and tab-bar controls work.
The last way to do this would be to put different buttons, in the same place, on each view and have them all trigger the same action. As far as the user is concerned this looks like the same button. Disadvantage here is that you can't alter the button across all views in a simple manner.