我有一个基本的 UIActivityViewController 共享一些文本和一个 URL。共享选项是电子邮件、SMS、Twitter 和 Facebook。在 iOS 6 中一切正常,但在 iOS 7 中,当我选择 Twitter 或 Facebook 时,无需触摸任何东西,我的设备会自动关闭我的应用程序,打开 Safari 并转到我尝试共享的 URL。这可能是什么原因造成的?
代码(CustomActivityItemProvider 是基于共享器自定义文本的子类):
if ([UIActivityViewController class]) { // if class exists = ios6+
// Create array for sharing
CustomActivityItemProvider *textToShare = [[CustomActivityItemProvider alloc]
initWithStandardText:@"Text to share.\n"];
NSURL *urlToShare = iTunesShort ? iTunesShort : [NSURL URLWithString:iTunesLink];
NSArray *activityItems = @[textToShare, urlToShare];
// Show sharing view
UIActivityViewController *activityVC = [[UIActivityViewController alloc]
initWithActivityItems:activityItems applicationActivities:nil];
activityVC.excludedActivityTypes = @[UIActivityTypePrint, UIActivityTypeCopyToPasteboard,
UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll];
[self presentViewController:activityVC animated:TRUE completion:nil];
}