swift 3:present不适用于iOS 9及更早版本

时间:2016-12-20 01:50:01

标签: ios xcode swift3

我试图呈现一个UIImagePickerController,当我使用时:

self.present(picker, animated: true, completion: nil)

我收到此错误:

'NSPersistentContainer' is only available on iOS 10.0 or newer

我希望我的应用支持iOS 8及更高版本

编辑: 选择器代码:

  if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.photoLibrary) {
        var imagePicker = UIImagePickerController()
        imagePicker.delegate = self
        imagePicker.sourceType = UIImagePickerControllerSourceType.photoLibrary
        imagePicker.allowsEditing = true
        self.present(imagePicker, animated: true, completion: nil)
    }

1 个答案:

答案 0 :(得分:0)

根据苹果文档:https://developer.apple.com/reference/coredata/nspersistentcontainer

我们可以在右侧看到:

  

的SDK

     

iOS 10.0+
     macOS 10.12+
     tvOS 10.0+
     watchOS 3.0 +

表示如果您开发iOS,NSPersistentContainer只能在iOS 10.0或更高版本中使用。您不能在iOS 8中使用,或者低于iOS 10