在iOS8上,我使用UIActivityViewController与Facebook/Twitter等共享UIImage。它似乎运转良好,但今天在我的iPad上运行代码时,它突然开始崩溃。但是,在模拟器中,它仍然可以正常工作。
我的代码:
UIActivityViewController *controller =
[[UIActivityViewController alloc]
initWithActivityItems:@[text, url, myImage]
applicationActivities:nil];
[self presentViewController:controller animated:YES completion:nil];一旦崩溃,Xcode就会吐出:
已发现的扩展:{( {id = com.apple.share.Facebook.post},{id = com.apple.share.Twitter.post},{id = com.apple.share.TencentWeibo.post},属性的{id = com.apple.share.SinaWeibo.post} }:{ NSExtensionActivationRule ={ extensionItems =({extensionItems=({ registeredTypeIdentifiers =)( "public.image“);},{ registeredTypeIdentifiers =(“public.plain.纯文本”);{ registeredTypeIdentifiers =( "public.url“);};};};NSExtensionPointName =( "com.apple.share-services“、"com.apple.ui-services”、"com.apple.services“);} 2014-08-07 21:38:59.208拼贴测试279:11021 LaunchServices: invalidationHandler称为2014-08-07 21:38:59.212拼贴测试279:11016已发现扩展:{( {id = com.apple.share.Flickr.post},{id =LaunchServices= com.apple.share.Twitter.post},{id = com.apple.share.Facebook.post},{id = com.apple.share.Vimeo.post},{id = com.apple.share.SinaWeibo.post},{id = com.apple.share.TencentWeibo.post} )属性:{ NSExtensionPointName = "com.apple.share-services";} 2014-08-07 21:38:59.216测试279:11021 LaunchServices: invalidationHandler调用
发布于 2014-08-08 13:32:52
查看医生们,我需要为popover控制器定义一个源视图。
UIActivityViewController *controller =
[[UIActivityViewController alloc]
initWithActivityItems:@[text,url,myImage]
applicationActivities:nil];
[self presentViewController:controller animated:YES completion:nil];
UIPopoverPresentationController *presentationController =
[controller popoverPresentationController];
presentationController.sourceView = self.view;发布于 2014-09-17 16:22:45
popoverPresentationController是iOS 8的新手,它将在iOS 7上崩溃,在iPhone上也将是零,因为它只出现在UIPopover on iPad中。这是克里斯蒂安在斯威夫特的回答,并考虑到了这些事实:
Swift 2.0 (Xcode 7)
let controller = UIActivityViewController(activityItems: [text, url, myImage], applicationActivities: nil)
presentViewController(controller, animated: true, completion: nil)
if #available(iOS 8.0, *) {
let presentationController = controller.popoverPresentationController
presentationController?.sourceView = view
}Swift 1.2 (Xcode 6)
let controller = UIActivityViewController(activityItems: [text, url, myImage], applicationActivities: nil)
presentViewController(controller, animated: true, completion: nil)
if controller.respondsToSelector("popoverPresentationController") {
// iOS 8+
let presentationController = controller.popoverPresentationController
presentationController?.sourceView = view
}发布于 2014-09-30 15:00:12
正如@mmccomb告诉这里的那样,在iPad上,活动视图控制器将使用新的UIPopoverPresentationController显示为弹出器。您至少需要指定源视图:
activityViewController.popoverPresentationController.sourceView = YOURDESIREDVIEW;如果要显示锚定到该视图的任何点的弹出窗口,请使用popoverPresentationController的popoverPresentationController属性指定它。
https://stackoverflow.com/questions/25192313
复制相似问题