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

2017-08-09  本文已影响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

上一篇 下一篇

猜你喜欢

热点阅读