0

我正在尝试共享一个 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];
4

1 回答 1

1

更改此行:

NSString *url=@"www.google.com";

至:

NSURL *url= [NSURL URLWithString:@"https://www.google.com"];

如果由于崩溃而这对您不起作用,则可能是其他地方的问题,但是请提供崩溃报告,也许我可以提供帮助。

于 2016-07-31T03:09:28.847 回答