UIImagePickerController on iPad with IOS9

前端 未结 7 1020
陌清茗
陌清茗 2021-02-01 03:06

Since iOS 9 and Xcode 7 I am no longer able to implemet a UIImagePickerController on an iPad (both device and simulator). The code below works on the iPad but only prior to iOS

7条回答
  •  囚心锁ツ
    2021-02-01 03:31

    This code is relatively similar to @pkc456, just a little shorter.

    This works perfectly for me:

       import UIKit
    
       class PostImageViewController: UIViewController,    UINavigationControllerDelegate, UIImagePickerControllerDelegate {
    
      @IBOutlet var imageToPost: UIImageView!
    
       @IBAction func chooseImage(sender: AnyObject) {
    
        var image = UIImagePickerController()
        image.delegate = self
        image.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
        image.allowsEditing = false //or true additional setup required.
    
        self.presentViewController(image, animated: true, completion: nil)
    
    }
    
             func imagePickerController(picker: UIImagePickerController,    didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?) {
    
    
    
        self.dismissViewControllerAnimated(true, completion:nil)
    
    }
    

    Does this work?

提交回复
热议问题