简体   繁体   中英

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.

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):

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

The solution as guided by @gabbler was to declare it optional as AnyObject. Then conditionally (if iOS8) change it to UIVisualEffectView.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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