2011-05-04 102 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