Created
April 22, 2010 00:41
-
-
Save tilomitra/374649 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//The first example is adding a subview to your MainWindow nib so that it loads a nib from another view controller. | |
//The following code goes in the AppDelegate.m under the following method | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
// Override point for customization after application launch | |
[window addSubview:switchViewController.view]; //replace switchViewController with your own viewController | |
[window makeKeyAndVisible]; | |
return YES; | |
} | |
//The second example shows how to add subviews to a viewController | |
//This would go in the view controller you are adding subviews to. | |
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
//In this case, BlueViewController is a viewController that is being called in this viewController (switchViewController) | |
BlueViewController *blueController = [[BlueViewController alloc] initWithNibName:@"BlueViewController" bundle:nil]; | |
self.blueViewController = blueController; | |
[self.view insertSubview:blueController.view atIndex:0]; //index 0 determines zindex. | |
[blueController release]; | |
} | |
//This example shows how to remove views (like the one above) | |
[yellowViewController.view removeFromSuperview]; | |
//You can also check to see if the view of a given viewController is present using the following: | |
if (self.blueViewController.view.superview == nil) { | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment