item-UIButton

資料鏈接:http://blog.csdn.net/totogo2010/article/details/7681879

1、添加UIBarButtonItem:


  1. - (void)viewDidLoad  

  2. {  

  3.     [super viewDidLoad];  

  4.   

  5.     UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(selectLeftAction:)];  

  6.     self.navigationItem.leftBarButtonItem = leftButton;  

  7.       

  8.     UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd  target:self action:@selector(selectRightAction:)];  

  9.     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;

}



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章