swift – 当调用UIActivityViewController时,IOS 8 iPad应用程序崩溃

swift – 当调用UIActivityViewController时,IOS 8 iPad应用程序崩溃,第1张

概述当在这个应用程序中在iPhone上调用UIActivityViewController时,它可以很好地工作,但是当在iPad上调用时,应用程序崩溃了.以下是我使用的代码: func shareButtonPress() { //when the share button is pressed, default share phrase is added, cropped image of 当在这个应用程序中在iPhone上调用UIActivityVIEwController时,它可以很好地工作,但是当在iPad上调用时,应用程序崩溃了.以下是我使用的代码:
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)}

正如您所看到的,我正在Swift中编程,在SpriteKit框架中,我不明白为什么应用程序崩溃.

我收到此错误:

Terminating app due to uncaught exception 'NSGenericException',reason: 'UIPopoverPresentationController (<_UIAlertControllerActionSheetRegularPresentationController: 0x7fc7a874bd90>) should have a non-nil sourceVIEw or barbuttonItem set before the presentation occurs.'

我该怎么做才能解决这个问题?

在演示UIActivityVIEwController之前,添加以下代码行:
activityVIEwController.popoverPresentationController?.sourceVIEw = self.vIEw

这样,视图控制器就知道要在哪个GameVIEwController框架中出现.

总结

以上是内存溢出为你收集整理的swift – 当调用UIActivityViewController时,IOS 8 iPad应用程序崩溃全部内容,希望文章能够帮你解决swift – 当调用UIActivityViewController时,IOS 8 iPad应用程序崩溃所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1035001.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存