报错信息
Assertion failure in void UIViewReportBrokenSuperviewChain(UIView *__strong, UIView *__strong, BOOL)(), /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3698.33.7/UIView.m:238
2018-06-12 19:22:51.389433+0800 sfs[7866:2179512] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'View has lost track of its superview, most likely through unsupported use of CALayer API on the view's layer. If this isn't a crash yet, it will be in the near future.
报错触发方式 - 模态切换进入新页面
网上搜索了相仿的报错,
帖子如:
Assertion failure in void UIViewReportBrokenSuperviewChain(UIView *__strong, UIView *__strong, BOOL)()
最后发现模态切换进入新页面后,在didload里面创建了一个自定义的barButton
造成bug的内部实现代码如下
[self.btn.layer addSublayer:midLabLabyer];
结合报错信息截图,确实是因为在button.layer视图上添加laber的layer视图造成的cash
解决方案
[self.btn addSubview:midLab];