AirDrop

前几天碰到个需求 需要在AirDrop中出现自己的app 经过几个小时的查资料 大致知道怎么回事了 实现起来也很简单 流程如下

Targets -> Info -> Document Type 中

UTI根据项目需要在https://developer.apple.com/library/content/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html 中自己选择

测试代码 AppDelegate.swift

func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {
  print(url)
  print(options)
  let controller = ViewController()
  controller.fileURL = url
  self.window?.rootViewController = UINavigationController(rootViewController: controller)
        return true
}
复制代码

ViewController.swift

class ViewController: UIViewController {
    var fileURL: NSURL!
    override func viewDidLoad() {
        super.viewDidLoad()
        let label = UILabel(frame: UIScreen.mainScreen().bounds)
        self.view.addSubview(label)
        label.numberOfLines = 0
        label.backgroundColor = UIColor.redColor()
        if self.fileURL != nil {
            label.text = String(self.fileURL!)
        }
    }
}
复制代码

最重要的是 AirDrop 模拟器是没有作用的 必须真机调试才可以!!!

转载于:https://juejin.im/post/5a329583f265da430a509c34

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值