这里在我的应用程序中,我在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 :(得分: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];
}