我已經添加了相機&照片庫到我的應用程序,但我想要做的是當有人選擇相機,拍攝照片並選擇它時,我希望它將用戶導向到新的viewcontroller並顯示那裏的圖像,而不是在按鈕所在的當前視圖上?如何從UIImagePickerController將圖像導入到新的VC? Swift
到目前爲止,從谷歌上爬起來,我設法得到新的視圖加載時,相機或圖書館被解僱,但現在我似乎無法弄清楚如何導入照片太新視圖呢?!
如果任何人都可以提供幫助,那就太好了。
繼承人下面我當前的代碼:
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func Camera(sender: AnyObject) {
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera) {
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = UIImagePickerControllerSourceType.Camera;
imagePicker.allowsEditing = false
self.presentViewController(imagePicker, animated: true, completion: nil)
}
}
@IBAction func Images(sender: AnyObject) {
let image = UIImagePickerController()
image.delegate = self
image.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
image.allowsEditing = false
self.presentViewController(image, animated: true, completion: nil)
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image:UIImage, editingInfo: [String : AnyObject]?) {
self.dismissViewControllerAnimated(true, completion: nil)
let svc = self.storyboard!.instantiateViewControllerWithIdentifier("imageViewer") as! ImageViewController
self.presentViewController(svc, animated: true, completion: nil)
}
}
太棒了,完美工作 – Charles