I'm just following the official Apple introduction tutorial for Swift and Xcode by making a FoodTracker app. I've got this error (see title).
我只是通过制作FoodTracker应用程序来关注Swift和Xcode的官方Apple介绍教程。我有这个错误(见标题)。
This is Xcode 7.2.1 I have imported UIKit
这是Xcode 7.2.1我已经导入了UIKit
Here's the code I have where the issue appears. I have all class protocols and delegates and everything.
这是我出现问题的代码。我有所有类协议和委托以及所有内容。
@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)
}
I would appreciate any help since I just started learning this language!
我很感激任何帮助,因为我刚开始学习这门语言!
2 个解决方案
#1
2
in your case (you are using xcode 7 -> swift 2) it has to be:
在你的情况下(你使用xcode 7 - > swift 2)它必须是:
presentViewController(imagePickerController, animated: true, completion: nil)
right now you are using swift3 syntax.
现在你正在使用swift3语法。
#2
0
Make sure that you have added your class to your current target. You can confirm it by right pane beside your code editor or storyboard whatever is open in your canvas! You can confirm it from 'file inspector'. Check 'membership targets' check the checkbox of current target to add your class to it if it is unchecked!
确保已将课程添加到当前目标。您可以通过代码编辑器或故事板旁边的右窗格确认它,无论您在画布中打开什么!您可以从“文件检查器”确认。检查“会员目标”,检查当前目标的复选框,如果未选中,则将其添加到其中!
#1
2
in your case (you are using xcode 7 -> swift 2) it has to be:
在你的情况下(你使用xcode 7 - > swift 2)它必须是:
presentViewController(imagePickerController, animated: true, completion: nil)
right now you are using swift3 syntax.
现在你正在使用swift3语法。
#2
0
Make sure that you have added your class to your current target. You can confirm it by right pane beside your code editor or storyboard whatever is open in your canvas! You can confirm it from 'file inspector'. Check 'membership targets' check the checkbox of current target to add your class to it if it is unchecked!
确保已将课程添加到当前目标。您可以通过代码编辑器或故事板旁边的右窗格确认它,无论您在画布中打开什么!您可以从“文件检查器”确认。检查“会员目标”,检查当前目标的复选框,如果未选中,则将其添加到其中!