解决方法
一个快速的解决方案是为viewWilldisappear:方法添加一个实现.一旦viewController响应后退按钮消失就会被触发.
- (void)viewWilldisappear:(BOOL)animated { //... //make you stuff here //... }
另一个解决方案是向后退按钮添加自定义响应器.您可以修改viewController的init方法,如下所示:
- (id)init { if (self = [super init]) { //other your stuff goes here //... //here we customize the target and action for the backBarButtonItem //every navigationController has one of this item automatically configured to pop back self.navigationItem.backBarButtonItem.target = self; self.navigationItem.backBarButtonItem.action = @selector(backButtonDidpressed:); } return self; }
然后可以使用选择器方法如下.请务必正确关闭viewController,否则您的导航控制器将不会按需要弹出.
- (void)backButtonDidpressed:(id)aResponder { //do your stuff //but don't forget to dismiss the viewcontroller [self.navigationController popViewControllerAnimated:TRUE]; }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。