我已經添加了一個相機&照片庫到我的應用程序,但我想要做的是當有人選擇相機,拍照並選擇它時,我希望它將用戶引導到新的視圖控制器並顯示那裏的圖像,而不是在按鈕所在的當前視圖上?如何在選擇/拍攝後將圖像從相機/相機膠捲傳遞到新視圖?
我在Google上搜索過,但沒有找到任何清晰或迅速的東西,因爲我對ObjC沒有任何瞭解,所以我不確定我所看到的是否正確!
這裏是下面我當前的代碼:
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 imageLoad = UIImagePickerController()
imageLoad.delegate = self
imageLoad.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
imageLoad.allowsEditing = false
self.presentViewController(imageLoad, animated: true, completion: nil)
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image:UIImage, editingInfo: [String : AnyObject]?) {
self.dismissViewControllerAnimated(true, completion: nil)
}
非常感謝josh! – Charles