简体   繁体   English

iOS7中的UIVisualEffectView

[英]UIVisualEffectView in iOS7

Below line of swift code works fine on iOS8 devices and simulators but on iOS7 simulator, gives EXC_BAD_ACCESS(code=1,address=0.x20) error with (lldb) in log. 下面的快速代码行在iOS8设备和模拟器上工作正常,但在iOS7模拟器上,则日志中显示(lldb)时出现EXC_BAD_ACCESS(code = 1,address = 0.x20)错误。

var blurEffectView = UIVisualEffectView(effect: UIBlurEffect(style: UIBlurEffectStyle.Light))

EDIT: Since this class is not available in iOS7, I have put this declaration inside an if block and only run it if iOS version is 8+ but now it throws unresolved identifier error elsehwere in the code where i am trying to remove this blur effect view (even though, I am checking if it was created): 编辑:由于此类在iOS7中不可用,因此我已将此声明放在if块中,并且仅在iOS版本为8+时才运行它,但是现在它在代码中抛出了无法解析的标识符错误,我正尝试删除此模糊效果视图(即使我正在检查它是否已创建):

if iosVersion >= 8 {
   blurEffectView.removeFromSuperview()
}

The solution as guided by @gabbler was to declare it optional as AnyObject. @gabbler指导的解决方案是将其声明为AnyObject可选。 Then conditionally (if iOS8) change it to UIVisualEffectView. 然后有条件地(如果是iOS8)将其更改为UIVisualEffectView。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM