2011-05-04 138 views
0

在我的應用程序中,我在viewWillAppear方法中編程創建了一個leftbarbuttonitem,我有兩次點擊兩次來工作,我的代碼如下。關於導航控制器

Code for creating UIBarButtonItem(left bar button) 

    goingBackButton = [[UIBarButtonItem alloc] init]; 
goingBackButton.title = @"Back"; 
goingBackButton.target = self; 
goingBackButton.action = @selector(backAction); 
self.navigationItem.leftBarButtonItem = goingBackButton; 
[goingBackButton release]; 


    Action code 

    - (IBAction) backAction { 

NSLog(@"Inside the backAction of uploadViewController"); 
[self.navigationController popViewControllerAnimated:YES]; 
    NSLog(@"Inside the backAction1 of uploadViewController"); 
    } 

回答

0

試試下面的代碼:

UIBarButtonItem *bar = [[UIBarButtonItem alloc]initWithTitle:@"back" style:UIBarButtonItemStyleDone target:nil action:@selector(back)]; 
self.navigationItem.leftBarButtonItem = bar; 
[bar release]; 

-(void)back 
{ 
[self.navigationController popViewControllerAnimated:YES]; 

} 
+0

我這個代碼也嘗試過,但在功能方面沒有任何變化。請有任何方式讓我知道。 – 2011-05-04 10:44:40

+0

感謝您的幫助 – 2011-05-04 10:45:00

+0

是否有任何網絡操作正在推送視圖控制器是推 – 2011-05-04 10:47:22