无法通过蓝牙共享URL(UIActivityViewController)

时间:2016-07-29 11:44:42

标签: ios objective-c bluetooth ios-bluetooth airdrop

我尝试共享网址,以便在Safari或任何网络浏览器中打开网址,但无法这样做。我已将其发送到我的MAC和MAC,将其作为文本文件打开,然后点击我即将进入safari但是在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];

1 个答案:

答案 0 :(得分:1)

更改此行:

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

为:

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

如果因为崩溃而无法为您工作,那么其他地方可能会出现问题,但可以提供崩溃报告,也许我可以提供帮助。