2
所以我在初始控制視圖中有一個按鈕,將用戶帶到相機界面。用戶在拍攝照片後返回到初始視圖控制器,但如果用戶未拍攝照片,如何關閉相機並在特定時間段後返回到初始頁面或其他頁面。如何在swift2中的xcode上關閉相機界面並打開不同的視圖控制器?
import UIKit
class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
@IBOutlet weak var CameraButton: UIButton!
@IBOutlet weak var photoLibrary: UIButton!
@IBOutlet weak var imageView: UIImageView!
@IBAction func cameraAction(sender: UIButton) {
let picker = UIImagePickerController()
picker.delegate = self
picker.sourceType = .Camera
presentViewController(picker, animated: true, completion: nil)
}
@IBAction func photoLibraryAction(sender: AnyObject) {
let picker = UIImagePickerController()
picker.delegate = self
picker.sourceType = .PhotoLibrary
presentViewController(picker, animated: true, completion: nil)
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
imageView.image = info [UIImagePickerControllerOriginalImage] as? UIImage;
dismissViewControllerAnimated(true, completion: nil)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}