Wenn ein UIActivityViewController auf dem iPhone in dieser App aufgerufen wird, funktioniert es perfekt, aber beim Aufruf auf einem iPad stürzt die App ab. Unten ist der Code, den ich verwendet:IOS 8 iPad App stürzt ab, wenn UIActivityViewController aufgerufen wird
func shareButtonPress() {
//when the share button is pressed, default share phrase is added, cropped image of highscore is added
var sharingItems = [AnyObject]()
var shareButtonHighscore = NSUserDefaults.standardUserDefaults().objectForKey("highscore") as Int!
sharingItems.append("Just hit \(shareButtonHighscore)! Beat it! #Swath")
UIGraphicsBeginImageContextWithOptions(UIScreen.mainScreen().bounds.size, false, 0);
self.view.drawViewHierarchyInRect(view.bounds, afterScreenUpdates: true)
var image:UIImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
sharingItems.append(image)
let activityViewController = UIActivityViewController(activityItems: sharingItems, applicationActivities: nil)
var barButtonItem: UIBarButtonItem! = UIBarButtonItem()
activityViewController.excludedActivityTypes = [UIActivityTypeCopyToPasteboard,UIActivityTypeAirDrop,UIActivityTypeAddToReadingList,UIActivityTypeAssignToContact,UIActivityTypePostToTencentWeibo,UIActivityTypePostToVimeo,UIActivityTypePrint,UIActivityTypeSaveToCameraRoll,UIActivityTypePostToWeibo]
self.presentViewController(activityViewController, animated: true, completion: nil)
}
Wie Sie sehen, ich bin Programmierung in Swift, im SpriteKit Framework und ich verstehe nicht, warum die App abstürzt.
Ich erhalte diese Fehlermeldung:
Terminating app due to uncaught exception 'NSGenericException', reason: 'UIPopoverPresentationController (<_UIAlertControllerActionSheetRegularPresentationController: 0x7fc7a874bd90>) should have a non-nil sourceView or barButtonItem set before the presentation occurs.'
Was kann ich tun, um dieses Problem zu beheben?
> Was kann ich tun, um dieses Problem zu beheben? - 1. Lesen Sie die Fehlermeldung. 2. Überprüfen Sie die Dokumentation auf 'UIPopoverController' – Mundi