标签:style blog color io 使用 ar for strong sp
.h:
#import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @property (nonatomic, strong) UINavigationController *navigationController; @end
.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ViewController *mainVC = [[ViewController alloc]init]; //self.window.rootViewController = mainVC; self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]]; [self.window makeKeyAndVisible]; self.navigationController = [[UINavigationController alloc]initWithRootViewController:mainVC]; [self.window addSubview:self.navigationController.view]; return YES; }
我计划在第一个视图控制器出现在屏幕上 5 秒后把第二个视图控制器 push 到它的顶部 :
在第一个视图中:
//推出第二个视图 - (void) pushSecondViewController{ SecondViewController *secondController = [[SecondViewController alloc]init]; [self.navigationController pushViewController:secondController animated:YES]; } - (void) viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; //5s后调用pushSecondViewController方法 [self performSelector:@selector(pushSecondViewController) withObject:nil afterDelay:5.0f]; }
- (void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; [self performSelector:@selector(goBack) withObject:nil afterDelay:5.0f]; } - (void)goBack{ [self.navigationController popViewControllerAnimated:YES]; }
UI: 使用 UINavigationController 实现导航
标签:style blog color io 使用 ar for strong sp
原文地址:http://www.cnblogs.com/safiri/p/4018549.html