1、添加UIBarButtonItem:
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(selectLeftAction:)];
- self.navigationItem.leftBarButtonItem = leftButton;
- UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(selectRightAction:)];
- self.navigationItem.rightBarButtonItem = rightButton;<p class="p1">}</p>
以上都是以后要用到得item。。。含义很明显,有了它们以后得item不再会乱用。。。
2、页面间切换:
主页面的设置:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
LZWelcomeViewController *rootController = [[LZWelcomeViewController alloc] init];
LZRootViewController *rootController1 = [[LZRootViewController alloc] init];
//之前错误之处:
//self.navController = [[UINavigationController alloc] initWithRootViewController:rootController];
//[self.navController setNavigationBarHidden:YES];
//[self.window addSubview:navController.view];
//welController = rootController;
//判断是不是第一次使用此应用,不是第一次则跳过WelcomeView
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"everLaunched"]) {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"everLaunched"];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firstLaunch"];
}
else{
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"firstLaunch"];
}
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"firstLaunch"]){
self.window.rootViewController = rootController;
}else{
self.window.rootViewController = rootController1;
}
[self.window makeKeyAndVisible];
return YES;
}