我试图将visualEffect添加到在iOS10和以前版本上正常工作的视图中......但在iOS 11上它崩溃了。UIVisualEffectView LoadVIew()
has been added as a subview to <UIVisualEffectView: 0x7feabe90d170; frame = (0 0; 375 812); layer = <CALayer: 0x6000006257c0>>. Do not add subviews directly to the visual effect view itself, instead add them to the -contentView."
我用下面的代码:错误原因如下
override func loadView() {
super.loadView()
// create the blur view
let blurView = UIVisualEffectView(effect: effect)
if let oldView = view {
blurView.frame = view.frame
oldView.translatesAutoresizingMaskIntoConstraints = false
blurView.contentView.addSubview(oldView)
blurView.contentView.pinParentAllDirections(oldView)
}
view = blurView
}
奇怪的是,当我在viewDidLoad中添加此代码它传递崩溃...任何人,请帮助我了解主要问题或者我错过iOS11的任何内容。
不,我不是..它完全来自代码 –
您是否按照@Hani Ibrahim的建议去除super.loadView()? – Rishi
我现在做了..但它进入loadView()出于某种原因的infinit循环 –