UIActivityViewController中缺少Airdrop选项
问题描述:
由于某些原因,当我从我的应用程序使用ActivityViewController时,我没有选择使用Airdrop进行共享。如果我用它从Chrome中,我得到的选项:UIActivityViewController中缺少Airdrop选项
这是我使用的代码:
NSMutableArray * items = [NSMutableArray new];
[items addObject:@"text for share"];
[items addObject:[UIImage imageNamed:@"image"]];
NSArray *activityItems = [NSArray arrayWithArray:items];
UIActivityViewController *activityViewController =
[[UIActivityViewController alloc] initWithActivityItems:activityItems
applicationActivities:nil];
[self presentViewController:activityViewController animated:YES completion:^{
.....
}];
但我只得到这样的:
如何添加Airdrop选项?
答
为了能够通过AirDrop发送某些内容,该项目需要是URL。我找不到官方文档,但在这个Apple AirDrop Example它指出:
URLs can be used as a simple way to transfer information between devices. Apps can easily parse a received URL to determine what action to take. After an app registers a URL scheme (including custom schemes), the system will know to launch that app when a URL of that type is received.
我看到你添加文本和图像到你的项目,你尝试使用只有一个或其他? –
这听起来像空投可能需要一个URL,你可以使用'fileURLWithPath'将你的图像转换为NSURL吗? –
让我试试看 – MXV