阅读背景:

如何为提示从图库或相机胶卷拍照的按钮创建警报视图?

来源:互联网 
import UIKitclass AccountViewController: UIViewController,UINavigationControllerDelegate, UIImagePickerControllerDelegate {@IBOutlet weak var imageView: UIImageView!@IBOutlet weak var chooseButton: UIButton!let imagePicker = UIImagePickerController()@IBOutlet weak var mySwitch: UISwitch!@IBOutlet weak var myStatus: UILabel!@IBAction func mySwitchTapped(sender: AnyObject) { updateSwitchStatus()}override func viewDidLoad() {    super.viewDidLoad()    updateSwitchStatus()    self.navigationController!.navigationBarHidden = true    self.view.backgroundColor = UIColor.whiteColor()    // Do any additional setup after loading the view.}override func didReceiveMemoryWarning() {    super.didReceiveMemoryWarning()    // Dispose of any resources that can be recreated.}func updateSwitchStatus(){    if mySwitch.on{        myStatus.textColor = UIColor(colorLiteralRed: 0.142, green: 0.742, blue: 0.146, alpha: 1.00)       myStatus.text = "I'M ONLINE"    }        else{        myStatus.textColor = UIColor(colorLiteralRed: 0.896, green: 0.085, blue: 0.000, alpha: 1.00)        myStatus.text = "I'M OFFLINE"    }}@IBAction func shootPhoto() {    imagePicker.allowsEditing = false    imagePicker.sourceType = UIImagePickerControllerSourceType.Camera    imagePicker.cameraCaptureMode = .Photo    imagePicker.modalPresentationStyle = .FullScreen    presentViewController(imagePicker,        animated: true,        completion: nil)}   @IBAction func btnClicked(){    if (UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.SavedPhotosAlbum)){        print("Button capture")        imagePicker.delegate = self        imagePicker.sourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum;        imagePicker.allowsEditing = false        self.presentViewController(imagePicker, animated: true, completion: nil)    }}func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: NSDictionary) {    self.dismissViewControllerAnimated(true, completion: {()-> Void in        })    imageView.image = image}import UIKitclass AccountViewController: UIView



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: