UIActivityViewController doesn't work in iOS 8

I was using UIActivityViewController to share something for my application. It works well in any device prior to iOS8. The problem is the text,images are not be shown in email, twitter, Facebook in iOS 8 device or simulator.

Here is my code:

    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];

Did I do anything wrong? Thanks.

EDIT:

The new Xcode 6.1 and iOS 8.1 doesn't solve the problem. And it causes crash in email. Here are some screenshots (take email sharing as an example):

  • In iOS 7 (You can see the image)
  • 在这里输入图像描述

  • In iOS 8 (Blank screen)
  • 在这里输入图像描述

    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: '* -[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


    在真实设备中似乎是正确的,但不是在模拟器中。


    I am encountering the same issue. however mine is slightly different. I can present the the controller without any actions available. :/ I have remove all of the excludedtypes hoping that I can see any but fails. I guess this is another bug with the latest release of xcode 6.1 and iOS8.

    链接地址: http://www.djcxy.com/p/81976.html

    上一篇: Django在DateField的auto中使用哪个时区

    下一篇: UIActivityViewController在iOS 8中不起作用