zoukankan      html  css  js  c++  java
  • *** Assertion failure in void UIViewReportBrokenSuperviewChain(UIView *__strong, UIView *__strong, BOOL)()

    *** Assertion failure in void UIViewReportBrokenSuperviewChain(UIView *__strong, UIView *__strong, BOOL)(), /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3600.7.47/UIView.m:189

    [Bugly]  Trapped 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.

    之前遇到了这个报错,是在返回上一个控制器时发生的,经过排查发现造成这个报错的原因:

    先创建了一个UIView A放在viewController.view上,又在viewA上添加了layer,然后在离开控制器时崩掉了,崩溃的原因是带有layer的viewA的父视图比viewA先移除,从上面的报错 View has lost track of its superview 也能看出。可以在viewWillDisappear时先把viewA移除,或者是在带layer的视图的父视图移除前,现将带layer的视图移除,就可以解决。

    遇到这个问题,可以先从自己的代码中有操作过layer的部分开始。

  • 相关阅读:
    [Luogu] P1886 滑动窗口
    [Luogu] P1195 口袋的天空
    [Luogu] P1331 海战
    [Luogu] P3952 时间复杂度
    运营活动如何防刷
    考研政治刷题小程序
    考研刷题小程序
    在线答题活动小程序
    知识竞答小程序v2.0
    知识竞答小程序
  • 原文地址:https://www.cnblogs.com/chzheng/p/7921192.html
Copyright © 2011-2022 走看看