From the standard view-based application, I found that the generated code did this:
self.window.rootViewController = self.viewController;
So I take it as such that the AppDelegate (self) has a local variable (declared property) named viewController, which is a subclass of UIViewController, and the self.window.rootViewController is pointed towards this view controller.
When a button is clicked on the screen, I would like to jump to a new view.
Now I have created a new subclass of UIViewController, say abcViewController, and a xib file which represents the view. Should I:
(1) replace “viewController” with “abcViewController” so that it becomes the new Application Delegate’s window’s new rootViewController
or
[self.view removeFromSuperview];
[self.parentViewController.view addSubview:abcViewController];
Do I add/remove the view directly, or should I swap the view controllers, then do something to change the view within that view controller? Do I also need a new subclass of UIViewController for every view that I would like to add to the App?
Do like this.
In viewController class on which event you want to switch the view at there use this,
-Make object of appDelegate class,
-then on this object access the window .
-Make object for new view
-and add it on window.
see this,