Ich hatte das gleiche Problem in iOS 9, und keine der vorgeschlagenen Lösungen I (hier oder auf ähnliche Fragen auf SO) funktionierte für mich gefunden. Aber ich fand eine Lösung mit dem UIPopoverPresentationController, der in iOS 8 eingeführt wurde. Das ist, was ich mache, in einer App, die nur auf dem iPhone im Hochformat und nur auf dem iPad im Querformat ist. In meinem AppDelegate, ich habe dies:
func application(application: UIApplication,
supportedInterfaceOrientationsForWindow window: UIWindow?)
-> UIInterfaceOrientationMask {
if UIDevice.currentDevice().userInterfaceIdiom == .Pad {
return .Landscape
} else {
return .Portrait
}
}
Dann im View-Controller, der das Foto Picker zeigen muss:
@IBAction func choosePictureFromLibrary() {
let imagePickerController = UIImagePickerController()
imagePickerController.delegate = self
// Set the presentation style and grab the presentation controller,
// which is created for you.
imagePickerController.modalPresentationStyle = .Popover
let presentationController = imagePickerController.popoverPresentationController
// You must set a sourceView or barButtonItem so that it can
// draw a "bubble" with an arrow pointing at the right thing.
presentationController?.sourceView = photoButton
self.presentViewController(imagePickerController, animated: true) {}
}
Mit dem .Popover
modal Präsentationsstil ein schönes, kompakten gibt (im Grunde iPhone Größe), die den Bildschirm auf dem iPad überlagert. Wenn Sie auf dem iPhone laufen, läuft es nur im Vollbildmodus wie eine normale modale Ansicht.
Ich habe nicht PUUIAlbumListViewController class.and App erstellt stürzt nach wie vor. – user1960279
Fügen Sie das obige Code-Snippet in alle View-Controller ein, einschließlich PUUIAlbumListViewController. – Saif
Ich glaube nicht, dass viele Leute außerhalb von Apple Zugriff auf PUUIAlbumListViewController haben, @saif –