4

比方說,我有兩個控制器A &乙......當我從A轉到B,則後退按鈕第B控制器將被A.的UINavigationController:如何管理取消按鈕和返回按鈕

所以我問題是...在一個按鈕上單擊我必須將backButton更改爲Cancel Button ..並且在另一個後退按鈕上它應該以後退按鈕箭頭樣式顯示backButton A.

請建議。

回答

9

執行以下操作,

SHOW取消按鈕:

- (void)showCancelButton { 

    UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(someMethod)]; 
    [self navigationItem] setLeftBarButtonItem:cancelButton]; 
    [cancelButton release]; 
} 

隱藏取消按鈕:

- (void)hideCancelButton { 

    [self navigationItem] setLeftBarButtonItem:nil]; 
} 

確保self.navigationController.navigationItem.hidesBackButton is NO

+0

感謝它的工作:) – Tariq

+0

歡迎!!!! ;-) – EmptyStack