替换NavigationController里面的返回按钮

通过navigationController push进来的controller,默认的返回按钮是将本controller pop出去。

 

但有时候想在pop出去前完成一些自己的一些事情,这时可以自己写一个按钮替换之。

 

self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc] initWithTitle:@"返回"style:UIBarButtonItemStylePlain target:self action:@selector(backToIndex)]; 

 

然后实现这个按钮绑定的事件:

 

-(void)backToIndex

{

    //do something.

    [self.navigationController popViewControllerAnimated:YES];

}

posted @ 2014-06-09 15:21  管小木  阅读(218)  评论(0编辑  收藏  举报