Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // main.m
- #import <UIKit/UIKit.h>
- int main(int argc, char * argv[]) {
- @autoreleasepool {
- return UIApplicationMain(argc, argv, nil, @"AppDelegate");
- }
- }
- // AppDelegate.m
- #import <UIKit/UIKit.h>
- @interface AppDelegate : UIResponder <UIApplicationDelegate>
- @property (strong, nonatomic) UIWindow *window;
- @end
- @interface A : UIViewController
- @end
- @interface B : UIViewController
- @end
- @implementation A
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.navigationItem.title = @"RED";
- self.view.backgroundColor = [UIColor redColor];
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- B *b = [[B alloc] init];
- [self.navigationController setViewControllers:@[b]];
- }
- @end
- @implementation B
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.navigationItem.title = @"GREEN";
- self.view.backgroundColor = [UIColor greenColor];
- }
- @end
- @implementation AppDelegate
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
- UINavigationController *nc = [[UINavigationController alloc] init];
- UIViewController *a = [[A alloc] init];
- [nc setViewControllers:@[a]];
- UIWindow *window = [[UIWindow alloc] init];
- window.backgroundColor = [UIColor whiteColor];
- window.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
- window.rootViewController = nc;
- [window makeKeyAndVisible];
- self.window = window;
- return YES;
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement