UIImagePickerController on iPad with IOS9

前端 未结 7 1023
陌清茗
陌清茗 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:55

    I am working on xcode 7.1(Swift) and found your code appropriate. I also wrote the below code on my project and it is working successfully.

    func showPicker(){
        let type = UIImagePickerControllerSourceType.PhotoLibrary
        if(UIImagePickerController.isSourceTypeAvailable(type)){
            let pickerController = UIImagePickerController()
            pickerController.delegate = self
            pickerController.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
            pickerController.allowsEditing = false
            self.presentViewController(pickerController, animated: true, completion: nil)
        }
    }
    
    func imagePickerController(picker: UIImagePickerController!, didFinishPickingImage image: UIImage!, editingInfo: NSDictionary!) {
        let imageView = self.view.viewWithTag(20) as! UIImageView
        let selectedImage : UIImage = image
        imageView.image=selectedImage
        self.dismissViewControllerAnimated(true, completion: nil)
    }
    

    The only difference in your code and my code is about visibility of ImagePickerController instance. For your reference, I upload my code at:- https://www.dropbox.com/s/pe0yikxsab8u848/ImagePicker-Swift.zip?dl=0

    My idea is just look at my code once, may be you will get an idea about which section of your code malfunctioning.

    0 讨论(0)
提交回复
热议问题