views:

63

answers:

2

In my iPhone application, I use a Tab Bar Controller with five items for the main navigation. However, I also need additional ways to change the current view. For example, if the user is on the Calendar tab and clicks on a date, they need to be shown a different view.

In order to implement this (and other) types of custom navigation, what do I do? I thought what I needed was to add the Navigation Controller to my Main Window nib, but this looks like it adds a navigation bar to the UI, so I don't think that's it. Basically, what is the best way to change the view when a user clicks on something like a button or item on a grid? I know how to hook these interface items to events, but don't quite get how the logic to change views goes in the Main Window nib.

Thanks!

EDIT: To clarify, I believe what I'm trying to do is navigate to a child view for that tab (not change the active tab). As Griffo commented, yes, I am trying to assemble most of the workings in IB and then tweak the code as necessary. I will be trying the approach from his attached link and reporting back.

A: 

I think this SO question answers your question

Griffo
Do I create my root ViewController and add it to my Main Window nib then? (Or does navigating in this way completely divorce it from the concept of a "nib"?) I'm trying to figure out how this process fits into Interface Builder (or doesn't).
Wickethewok
In the example you give you say the user may need to be taken to a different view if they tap on a button or whatever. So, for each of those situations, you need to decide whether it takes them to another tab on your tab bar, a parent of the current view or a child of the current view. You can avoid using IB altogether if you want, there are posts on SO which show how to do this and several books follow this approach. I find it easier to do most stuff in IB and then tweak manually in code if needed. If you need guidance on something more specific then make your question more specific ;o)
Griffo
A: 

Hi. How about showing modal dialog? For instance if you have UIButton in your tab controller:

  1. associate it with method:

    [myButton addTarget:self action:@selector(onDoSomething:) forControlEvents: UIControlEventTouchUpInside];

  2. in method -(void)onDoSomething:(id)_sender open your modal dialog:

    [self presentModalViewController:mDoingsomethingController animated:YES];

  3. implement "doing something" controller class and supply it with 'done' button and method 'onDone' containing

    [self dismissModalViewControllerAnimated:YES];

Pavel