美文网首页
懒加载wkwebview,在viewdidload中调用偶尔会c

懒加载wkwebview,在viewdidload中调用偶尔会c

作者: 多多蘸酱 | 来源:发表于2017-08-09 14:11 被阅读0次

懒加载中用masonry定义wbwebview的布局,

在viewdidload中loadrequest,偶尔会crash,错误如下:

[Warning] Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior ()

2017-08-09 11:40:44.631248 caishen[7432:2496466] *** Assertion failure in -[MASViewConstraint setSecondViewAttribute:], 

断点定位在[MASViewConstraint setSecondViewAttribute]

抓耳挠腮头疼脑热之后才恍然大悟,在viedidload是,self.view有可能是nil,而此时让wkwebview去loadrequest会执行懒加载方法,masonry设定布局是找不到self.view必然就crash了.

解决办法:在viewwillappear中让wkwebview loadrequest

相关文章

网友评论

      本文标题:懒加载wkwebview,在viewdidload中调用偶尔会c

      本文链接:https://www.haomeiwen.com/subject/yoafrxtx.html