NavigationController and Modal Views
I am a newbie to iOS world and have started building custom code on top of
a templated code. So excuse me for the obvious.
The View chain starts with a MainWindow.xib which contains a App Delegate
Object, a Window Object and Application ViewController. I dont understand
why those objects are needed over there. But what I understand, I need to
mention starting ViewController in the "Nib Name" Property to initiate my
custom View Controller (called "EmptyViewController"). Its a dummy view
controller, just there to avoid crash to happen as a result of missing
valid viewcontroller.
I initiate a separate Modal View Controller(MainViewController) inside
didFinishLaunchingWithOptions. Code for initiating modal View Controller
--
self.window.rootViewController = self.viewController;
mainView = [[MainViewController alloc]
initWithNibName:@"MainViewController" bundle:nil];
// present the viewcontroller
UINavigationController *navController = [[UINavigationController alloc]
initWithRootViewController:mainView];
[self.viewController presentModalViewController:navController animated:NO];
// release it, because it's retained as modalViewController
[navController release];
I do not put this MainViewController inside MainWindow.xib as I want to
have navigation at the root of MainViewController. Inside
MainViewController, I push HelpViewController when "help" button is
pressed. But HelpViewController does not show any navigation bar. I do not
understand why?
Code for Pushing Navigation bar --
HelpViewController *helpVC = [[HelpViewController alloc] init];
[self.navigationController pushViewController:helpVC animated:YES];
[helpVC release];
So I would like to understand -- 1) Why is MainWindow.xib needed? Can I
remove it? (Note: I tried to remove it, but then I get blank screen) 1.a)
Why are all the controls/objects App Delegate Object, a Window Object and
Application ViewController objects needed?
2) Why doesnt HelpViewController show Navigation bar? 3) Another thing I
noticed, if I say self.presentingViewController, EmptyViewController
handle is returned while popViewController returns me back to
MainViewController.
Thanks
No comments:
Post a Comment