iOS 13点击返回按钮闪退问题的解决办法[UINavigati
2019-12-17 本文已影响0人
Sxiaobai
Assertion failure in -[UINavigationController _popNavigationBar:item:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore/UIKit-3899.13.13/UINavigationController.m:8520
创建UINavigationController
的自定义类,然后如下所示添加UINavigationBarDelegate
,并将该类分配给UINavigationController
swift
class SJMNavigationController: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()
self.navigationBar.delegate = self
}
}
extension SJMNavigationController : UINavigationBarDelegate {
public func navigationBar(_ navigationBar: UINavigationBar, shouldPop item: UINavigationItem) -> Bool {
return true
}
}
oc
@interface SJMNavigationController () <UINavigationBarDelegate>
@end
@implementation SJMNavigationController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
// self.navigationBar.delegate = self;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#ifdef __IPHONE_13
- (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(nonnull UINavigationItem *)item {
return YES;
}
#endif