我只是通过制作 FoodTracker 应用程序来遵循 Swift 和 Xcode 的官方 Apple 介绍教程。 我遇到了这个错误(见标题)。
这是 Xcode 7.2.1 我导入了 UIKit
这是出现问题的代码。我有所有的类协议(protocol)和代表等等。
@IBAction func selectImageFromPhotoLibrary(sender: UITapGestureRecognizer) {
nameTextField.resignFirstResponder()
// UIImagePickerController is a view controller that lets a user pick media from their library.
let imagePickerController = UIImagePickerController()
// Only allow photos to be picked, not taken.
imagePickerController.sourceType = .PhotoLibrary
// Make sure ViewController is notified when the user picks an image.
imagePickerController.delegate = self
present(imagePickerController, animated: true, completion: nil)
}
我将不胜感激,因为我刚刚开始学习这门语言!
最佳答案
在你的情况下(你使用的是 xcode 7 -> swift 2)它必须是:
presentViewController(imagePickerController, animated: true, completion: nil)
现在您正在使用 swift3 语法。
关于ios - 在 Swift 中使用未解析的标识符 'present'(Apple 教程),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41537168/