如何以编程方式创建导航控制器的后退按钮?
答案 0 :(得分:25)
在-(void)loadView
或类似内容中:
UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithTitle:@"back" style:UIBarButtonItemStyleBordered target:self action:@selector(backPressed:)];
self.navigationItem.leftBarButtonItem = btn;
[btn release];
-(void)backPressed: (id)sender
{
[self.navigationController popViewControllerAnimated: YES]; // or popToRoot... if required.
}