Chr*_* B. 10 uiactivityviewcontroller ios8
在iOS8上,我正在使用UIActivityViewController与Facebook/Twitter等共享UIImage.它似乎工作正常,但今天它在我的iPad上运行代码时突然崩溃了.但是,它仍然可以在模拟器中按预期工作.
我的代码:
UIActivityViewController *controller =
[[UIActivityViewController alloc]
initWithActivityItems:@[text, url, myImage]
applicationActivities:nil];
[self presentViewController:controller animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
崩溃后,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})} for attributes:{NSExtensionActivationRule = {extensionItems =({attachments =({registeredTypeIdentifiers =("public.image");},{registeredTypeIdentifiers =("public.plain-text" );},{registeredTypeIdentifiers =("public.url");});}); }; NSExtensionPointName =("com.apple.share-services","com.apple.ui-services","com.apple.services"); 2014-08-07 21:38:59.208 collageTest [279:11021] LaunchServices:invalidationHandler被称为2014-08-07 21:38:59.212 collageTest [279:11016]发现的扩展:{({id = com.apple.share .Flickr.post},{id = com.apple.mobileslideshow.StreamShareService},{id = 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})} for attributes:{NSExtensionPointName ="com.apple.共享服务"; 2014-08-07 21:38:59.216 collageTest [279:11021] LaunchServices:invalidationHandler被调用
Chr*_* B. 14
看一下这些文档,我需要为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;
Run Code Online (Sandbox Code Playgroud)
And*_*rew 14
popoverPresentationController对iOS 8来说是新手,并且会在iOS 7上崩溃.它在iPhone上也是零,因为它只UIPopover在iPad上.这是克里斯蒂安在斯威夫特的答案,考虑到这些事实:
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
}
Run Code Online (Sandbox Code Playgroud)
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
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11400 次 |
| 最近记录: |