UIImagePickerController on iPad with IOS9

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

    for me I was solved, showing mode as popover

      @IBAction func photoButton(sender: AnyObject) {
    
        imagePicker.allowsEditing = true
        imagePicker.sourceType = .PhotoLibrary
    
        let controller = self.imagePicker
    
    
        controller.modalPresentationStyle = UIModalPresentationStyle.Popover
        controller.modalTransitionStyle = UIModalTransitionStyle.CoverVertical
        let popover = controller.popoverPresentationController
    
        popover?.sourceView = self
        controller.preferredContentSize = CGSize(
            width: self.frame.width * 0.6,
            height: self.frame.height * 0.6
        )
    
        popover?.sourceRect = CGRectMake(
            CGRectGetMidX(self.bounds),
            CGRectGetMidY(self.bounds),
            0,
            0
        )
    
    
        self.presentViewController(self.imagePicker, animated: true, completion: nil)
    }
    

提交回复
热议问题