i wrote a function, that takes an enumeration value as argument. I don't get any errors for the function prototype, but as soon as i try to call the function an an block, ill get an error saying "Use of unresolved identifier":
@IBAction func addButtonPressed(sender: AnyObject) {
let actionMenu = UIAlertController(title: "Take a Photo or choose an
existing one", message: nil, preferredStyle:
UIAlertControllerStyle.ActionSheet)
let takePhotoAction = UIAlertAction(title: "take Photo", style: UIAlertActionStyle.Default, handler: {(alert: UIAlertAction!) -> Void in
println("take Photo")
})
let choosePhotoAction = UIAlertAction(title: "choose an existing Photo", style: UIAlertActionStyle.Default, handler: {(alert: UIAlertAction!) -> Void in
println("choose Photo")
//getting error right here
self.displayPickerController(UIImagerPickerControllerSourceType.PhotoLibrary)
})
actionMenu.addAction(takePhotoAction)
actionMenu.addAction(choosePhotoAction)
presentViewController(actionMenu, animated: true, completion: nil)
}
// MARK: - Helper Methods
func displayPickerController(withSource: UIImagePickerControllerSourceType){
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = withSource
presentViewController(imagePicker, animated: true, completion: nil)
}
You have a typo in self.displayPickerController(UIImagerPickerControllerSourceType.PhotoLibrary)
. You typed UIImager
instead of UIImage
when naming the enum.
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.