UIActivityViewController在presentViewController上崩溃:

时间:2014-11-25 03:55:37

标签: xcode uiactivityviewcontroller

上周没问题,但今天当我使用UIActivtyViewController时,uiactivityviewcontroller崩溃了。

- (void)shareThePrice
{
    UIImage *screenShotImg = [self screenShot];
    NSString *string = NSLocalizedString(@"shareString", nil);

    UIActivityViewController *activityViewController = [[UIActivityViewController alloc]
        initWithActivityItems:@[string,screenShotImg] applicationActivities:nil];

    [activityViewController setCompletionWithItemsHandler:
    ^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *error)
    {
        if ( completed ) {
            //  TODO error handling
            NSLog(@"share complete");
            //            NSExtensionItem* extensionItem = [returnedItems firstObject];
            //            NSItemProvider* itemProvider = [[extensionItem attachments] firstObject];
        } else {
            NSLog(@"canceld");
        }
    }];

    [self presentViewController:activityViewController animated:YES completion:^{
        NSLog(@"complete");
    }];
}

当方法presentViewController:使用时,它崩溃了。 我不知道出了什么问题?

Communications error: <OS_xpc_error: <error: 0x107f39b10> { count = 1, contents =
    "XPCErrorDescription" => <string: 0x107f39f18> { length = 22, contents = "Connection interrupted" }
}>

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSMutableArray removeObjectsAtIndexes:]: index set cannot be nil'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000105209f35 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010476cbb7 objc_exception_throw + 45
    2   CoreFoundation                      0x0000000105142278 -[NSMutableArray removeObjectsAtIndexes:] + 536
    3   UIKit                               0x0000000106b23dd8 _UIApplicationExtensionDiscoveryGetPostprocessedExtensions + 188
    4   UIKit                               0x0000000106b23a33 -[_UIActivityApplicationExtensionDiscovery activitiesMatchingInputItems:sourceIsManaged:error:updateBlock:] + 1032
    5   UIKit                               0x0000000106a13cea -[UIActivityViewController _availableActivitiesForItems:applicationExtensionActivities:] + 464
    6   UIKit                               0x0000000106a14cc4 -[UIActivityViewController viewDidLoad] + 157

0 个答案:

没有答案