0

I'd like to create an app without using the fancy iOS navigation bar. What's the best or most correct way to change between full screens?

So say I start on "Home", and I want to go to "LogIn" without using the navigation bar -- what should I do? Should I change rootViewController? And when I swap in the new view, how do I make sure the old view is completely released? I imagine with ARC if there's no references it will merely disappear? And pre-ARC I have to set everything to null?

Or is the correct way to hide the navigation bar and use its stack?

Thanks!

4

2 回答 2

2

Use the normal UINavigationController and set the navigation bar to hidden. Quite easy.

于 2012-12-07T16:32:44.353 回答
1

You can't use the default UINavigationController with the default segues if you don't want a stack. If you want all the views behind the destination to be released they have to be removed from the stack as the destination goes on screen.

My answer would be to put everything in a navigation controller, set the bar to hidden (self.navigationController.navigationBarHidden = YES;) and create a custom segue that overrides the perform method like this:

- (void) perform {
    UIViewController* destination = self.destinationViewController;
    NSArray* newStack = [NSArray arrayWithObject:destination];
    UIViewController* source = self.sourceViewController;
    [source.navigationController setViewControllers: newStack animated: YES];
}

Then, wire everything up like normal and make the segues your custom class. That way any time you segue the stack will be cleared of everything but the newly visible controller.

EDIT: I'm guessing you edited to clarify that you wanted to use that stack whilst I was writing this. Oh, well. In that case, yeah, just set the bar to hidden and use like normal.

于 2012-12-07T17:02:57.887 回答