我需要创建一个像页面一样的视图
,有一个弹出窗口,我可以选择从我的图书馆中选择一张照片或创建一个新照片.
目前,我有一个ViewController,呈现为Popover.在ViewController中,我插入了一个ContainerView,并声明它的类是UIImageViewController.这向我展示了照片库,但我找不到如何选择:我的ViewController呈现为Popover.
当我选择一张照片时,一切都没有发生.我试过放一些功能
(func imagePickerController(picker: UIImagePickerController!, didFinishPickingImage image: UIImage!, editingInfo: NSDictionary!))
Run Code Online (Sandbox Code Playgroud)
在我的ViewController中,但它不起作用.我已经读过UIImagePickerController不支持子类化,所以Pages如何做这个东西?
这是我的ViewController代码:
import UIKit
class MenuAddResources: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
var newMedia: Bool?
let imagePicker = UIImagePickerController()
@IBAction func takePhoto(sender: AnyObject) {
if(UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera)){
//load the camera interface
let picker : UIImagePickerController = UIImagePickerController()
picker.sourceType = UIImagePickerControllerSourceType.Camera
picker.delegate = self
picker.allowsEditing = false
self.presentViewController(picker, animated: true, completion: nil)
self.newMedia = true
}
else{
//no camera available
let alert = UIAlertController(title: NSLocalizedString("ERROR", comment: ""), message: NSLocalizedString("NO_CAMERA", comment: ""), …Run Code Online (Sandbox Code Playgroud)