ios8 – UIActivityViewController在iOS 8中不起作用

前端之家收集整理的这篇文章主要介绍了ios8 – UIActivityViewController在iOS 8中不起作用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用UIActivityViewController为我的应用程序分享一些东西.它适用于iOS8之前的任何设备.问题是文本,图像不会显示在iOS 8设备或模拟器中的电子邮件,推特,Facebook中.

这是我的代码

NSString *textObject = @"Test";
    NSString *urlString = @"http://test.com";
    UIImage* image = [UIImage imageNamed:@"logo"];
    NSURL *url = [NSURL URLWithString:urlString];

    NSArray *activityItems = [NSArray arrayWithObjects:textObject,url,image,nil];

    UIActivityViewController *avc = [[UIActivityViewController alloc]
                                     initWithActivityItems:activityItems
                                     applicationActivities:nil];

    avc.excludedActivityTypes = @[UIActivityTypePostToWeibo,UIActivityTypeAssignToContact,UIActivityTypeCopyToPasteboard ];

    [self presentViewController:avc animated:YES completion:nil];

我做错了什么吗?谢谢.

编辑:

新的Xcode 6.1和iOS 8.1无法解决问题.它会导致电子邮件崩溃.以下是一些截图(以电子邮件共享为例):

>在iOS 7中(你可以看到图像)

>在iOS 8(空白屏幕)

And the app crashes with a “MailCompositionService” exception. The
part of the error message is:

Process: MailCompositionService [3775] Path:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/Applications/MailCompositionService.app/MailCompositionService
Identifier: MailCompositionService Version:
1.0 (1.0) Code Type: X86-64 (Native) Parent Process: launchd_sim [3725] Responsible: launchd_sim [3725] User ID:
501

Date/Time: 2014-10-22 10:31:19.064 +0800 OS Version:
Mac OS X 10.10 (14A389) Report Version: 11 Anonymous UUID:
B1EC6B56-DD7F-36A3-1506-B8CE84AB3FEB

Time Awake Since Boot: 9800 seconds

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_CRASH (SIGABRT) Exception Codes:
0x0000000000000000,0x0000000000000000

Application Specific Information:
* Terminating app due to uncaught exception ‘NSInvalidArgumentException’,reason: ‘*@H_404_40@ -[NSRegularExpression
enumerateMatchesInString:options:range:usingBlock:]: nil argument’
terminating with uncaught exception of type NSException abort() called
CoreSimulator 110.4 – Device: iPhone 6 – Runtime: iOS 8.1 (12B411) –
DeviceType: iPhone 6

解决方法

它似乎在真实设备中是正确的,但在模拟器中却没有.

猜你在找的iOS相关文章