我正在尝试共享一个 URL,以便应该在 Safari 或任何网络浏览器中打开该 URL,但无法这样做。我已将其发送到我的 MAC,MAC 将其作为文本文件打开,然后单击我要去野生动物园,但如果是 iPhone,我很难打开它。如果是 NSURL,我的应用程序会崩溃,但有一些例外。这是我的代码
NSString *url=@"www.google.com";
UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:@[url] applicationActivities:nil];
// Exclude all activities except AirDrop.
NSArray *excludedActivities = @[UIActivityTypePostToTwitter, UIActivityTypePostToFacebook,
UIActivityTypePostToWeibo,
UIActivityTypeMessage, UIActivityTypeMail,
UIActivityTypePrint, UIActivityTypeCopyToPasteboard,
UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll,
UIActivityTypeAddToReadingList, UIActivityTypePostToFlickr,
UIActivityTypePostToVimeo, UIActivityTypePostToTencentWeibo];
controller.excludedActivityTypes = excludedActivities;
// Present the controller
[self presentViewController:controller animated:YES completion:nil];