邮件UIActivityViewController没有解雇

时间:2013-01-16 16:43:40

标签: ios

我有一个UIActivityViewController,它不会关闭iPad上的Mail对话框。该代码是Apple示例的标准代码,在iPhone上运行良好。

   NSString* someText = [NSString stringWithFormat:@"%@ Is really cool, sent from Element Story. en.wikipedia.info/wiki/%@",
                          [_detailItem description], [_detailItem description]];

   ActivityViewCustomProvider *customProvider =
    [[ActivityViewCustomProvider alloc]init];

    NSArray *items = [NSArray arrayWithObjects:customProvider,imageView.image,someText, nil];

    //ActivityViewCustomActivity *ca = [[ActivityViewCustomActivity alloc]init];


    // ...or whatever pieces of data you want to share.
    UIActivityViewController *activityVC =
    [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];
                                      //applicationActivities:[NSArray arrayWithObject:ca]];

activityVC.excludedActivityTypes = @[UIActivityTypeAssignToContact, UIActivityTypePrint, UIActivityTypeCopyToPasteboard];
    [self presentViewController:activityVC animated:YES completion:^{}];

1 个答案:

答案 0 :(得分:3)

我假设你是从splitviewcontroller显示这个,这也是我遇到的问题。基本上,您需要从主视图中显示UIActivityViewController。

所以而不是

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

类似的东西:

[[[self parentViewController] parentViewController] presentViewController:activityVC animated:YES completion:nil];

不幸的是它看起来不太好,因为它会在整个视图中显示选项,而不仅仅是在导航端或细节方面的上下文中,但它会起作用。