1. 程式人生 > >如何讓主介面NavigationBar隱藏,而push到的下一個介面顯示NavigationBar?

如何讓主介面NavigationBar隱藏,而push到的下一個介面顯示NavigationBar?

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    [self.navigationController setNavigationBarHidden:YES animated:animated];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];

    [self.navigationController setNavigationBarHidden:NO animated:animated];
}

注意,animated設為YES,仍是會有一個瞬間的過渡效果。只有設定為animated才能真正實現。

另外,把你的navagiatioincontroller的型別設定成不顯示navigationbar的.

摘錄於:http://www.cocoachina.com/bbs/read.php?tid=99139