Ich versuche, ein Bild in der Fotobibliothek in Swift 3 zu speichern (ich arbeite mit Xcode 8).iOS 10 App stürzt beim Versuch ab, Bild in Fotobibliothek zu speichern
Viewcontroller-Code:
func shareImage(image: UIImage) {
let items = [image]
var activityVC: UIActivityViewController = UIActivityViewController(activityItems: items, applicationActivities: nil)
let excludeActivities: [UIActivityType] = [UIActivityType.airDrop,
UIActivityType.assignToContact,
UIActivityType.addToReadingList,
UIActivityType.copyToPasteboard]
activityVC.excludedActivityTypes = excludeActivities
self.present(activityVC, animated: true, completion: nil)
}
Wenn ich die Anwendung ausführen, und klicken Sie auf die Schaltfläche den Screenshot nehmen (es zu Bild konvertieren, ..., das ist alles perfekt funktioniert), fragt die App für die Erlaubnis, Um auf die Fotobibliothek zuzugreifen, tippe ich auf die Schaltfläche "OK" und die App stürzt ab. Das Bild wird nicht in der Fotobibliothek gespeichert.
Der einzige Hinweis ich von Xcode erhalten, ist die folgende:
2016-09-28 11:24:27.216043 Ajax Kids[4143:1545362] [error] error: -addPersistentStoreWithType:SQLite configuration:(null) URL:file:///var/mobile/Media/PhotoData/Photos.sqlite?readonly_shm=1 options:{
NSPersistentStoreFileProtectionKey = NSFileProtectionCompleteUntilFirstUserAuthentication;
NSReadOnlyPersistentStoreOption = 1;
NSSQLitePersistWALOption = 1;
NSSQLitePragmasOption = {
"journal_mode" = WAL;
};
} ... returned error Error Domain=NSCocoaErrorDomain Code=256 "The file couldn’t be opened." UserInfo={reason=Failed to access file: 1} with userInfo dictionary {
reason = "Failed to access file: 1";
}
2016-09-28 11:24:27.216433 Ajax Kids[4143:1545362] [Migration] Unexpected error opening persistent store <private>, cannot attempt migration <private>)
2016-09-28 11:24:27.216568 Ajax Kids[4143:1545362] [Migration] Failed to open store <private>. Requires update via assetsd (256: <private>)
Hat keine Ahnung, jemand, wie dieses Problem beheben?
Vielen Dank im Voraus!
UPDATE
das Bild auf Social Media-Sharing funktioniert gut, so dass das Problem angegeben wird, um das Bild in der Fotobibliothek zu speichern.
Share Code, wenn Sie versuchen, Bild zu speichern –
@OlegGordiichuk Das ist alles, was ich geschrieben habe, um Bild zu teilen/speichern. Das OS kümmert sich beispielsweise um den Sicherungscode oder um das Bild auf Facebook zu posten. Das ist Code, den Sie nicht mit einem UIAcrtivityViewController schreiben müssen. – Charlotte1993
Sie sollten die Erlaubnis in der Zopf-Datei hinzufügen –