最近我的应用程序拒绝了App Review,因为我没有使用Popover。 然后我将编码改为以下。但我仍然没有在模拟器中获得弹出窗口。
总是获得正常的iPhone照片选择方法,它会让应用程序崩溃。
它甚至不打印"工作"。
@IBAction func chooseGallery(sender: UIBarButtonItem) {
imagePicker.sourceType = .PhotoLibrary
//imagePicker.modalPresentationStyle = .Popover
//presentViewController(imagePicker, animated: true, completion: nil)//4
//imagePicker.popoverPresentationController?.barButtonItem = sender
if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
self.presentViewController(imagePicker, animated: true, completion: nil)
}
else {
println("Working")// to test this part
imagePicker.modalPresentationStyle = .Popover
presentViewController(imagePicker, animated: true, completion: nil)//4
imagePicker.popoverPresentationController?.barButtonItem = (sender)
imagePicker.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.Up
imagePicker.popoverPresentationController?.sourceRect = CGRect(x: 150, y: 150, width: 0, height: 0)
}
}
答案 0 :(得分:0)
试试这个,
picker.modalPresentationStyle = .CurrentContext