gpt4 book ai didi

ios - 在 Swift 中使用未解析的标识符 'present'(Apple 教程)

转载 作者:搜寻专家 更新时间:2023-11-01 07:17:10 25 4
gpt4 key购买 nike

我只是通过制作 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com