AirDrop iOS 7的新功能

Sal*_*ani 4 ios7 airdrop

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

任何帮助都非常感谢,谢谢.

小智 9

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


Nab*_*ani 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];
Run Code Online (Sandbox Code Playgroud)

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

  • 您只能使用几种文件类型.从文档"使用此服务时,您可以提供NSString,NSAttributedString,UIImage,ALAsset和NSURL对象作为活动项的数据.您还可以指定其内容使用资产库方案的NSURL对象." 所以基本上是一个字符串,URL或图像.https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIActivity_Class/Reference/Reference.html#//apple_ref/occ/cl/UIActivity (3认同)