遇到需要重写导航返回事件,因为是用的系统的NavigationController ,查了下网上的资料,需要重写什么的,挺麻烦的,看到有人说自己写个通明的button,就试了下。
btn_back = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_TOP, JX_SCREEN_TOP)];
[btn_back addTarget:self action:@selector(onBack) forControlEvents:UIControlEventTouchUpInside];
[self.navigationController.navigationBar addSubview:btn_back];
- (void)onBack
{
//不移除的话跳转之后导航栏的返回键就被挡住不管用了,也不报错
[btn_back removeFromSuperview];
for (UIViewController *vc in self.navigationController.viewControllers) {
if ([vc isKindOfClass:[NTESMyWalletVC class]]) {
[self.navigationController popToViewController:vc animated:YES];
}
}
}
网友评论