4

我正在尝试AirDrop在我的 iOS 应用程序中实现功能。但是,我找不到有关此功能的任何特定教程或资源。有人可以向我提供有关AirDrop在 iOS 7 中实现该功能的示例或链接吗?

非常感谢任何帮助,谢谢。

4

3 回答 3

9

Airdrop 是添加到当前可用的UIActivityViewController中的一项功能。如果用户在受支持的设备(iPad mini、iPad 4、iPhone 5、iPhone 5c、iPhone 5s)上安装了 iOS7,那么他们应该可以使用空投作为另一种选择,除非您明确排除该活动。

于 2013-09-12T21:57:06.087 回答
5

试试这个,它的内置功能。在您的按钮选择器中执行此操作。

UIDocumentInteractionController *interaction = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:fileToTransferPath]];
//fileToTransferPath can be the path of a file supported by airdrop feature.
interaction.delegate = self;
[interaction presentOpenInMenuFromRect:sender.frame inView:self.view animated:NO];

不要忘记在 .h 文件中添加 UIDocumentInteractionControllerDelegate。

于 2013-09-20T07:02:23.067 回答
1

假设您想与某人共享 URL。您可以使用 UIActivityViewController 执行此操作:

// Build a collection of activity items to share, in this case a url
NSArray *activityItems = @[[NSURL URLWithString:link]];

// Build a collection of custom activities (if you have any)
NSMutableArray *customActivities = [[NSMutableArray alloc] init];


UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:customActivities];

[self presentViewController:activityController animated:YES completion:nil];

这也可以让您自动访问其他社交共享功能,除非您通过 customActivities 集合禁用它们。

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIActivityViewController_Class/Reference/Reference.html

于 2013-09-19T22:44:18.090 回答