iOS 11丢弃网址返回无

时间:2017-08-08 19:22:03

标签: ios swift ios11

我正在尝试使用以下代码将URL从Safari拖到集合视图中,然后让它打印URL。

func collectionView(_ collectionView: UICollectionView, performDropWith coordinator: UICollectionViewDropCoordinator) {
    for item: UIDragItem in coordinator.session.items {
        item.itemProvider.loadItem(forTypeIdentifier: kUTTypeURL as String, options: nil, completionHandler: { (url, error) in
            if let myURL = url as? URL {
                print (myURL)
            }
        })
    }
}

问题是永远不会调用print (myURL)行,myURL为零。

我不确定为什么这不起作用session.hasItemsConforming(toTypeIdentifiers: [kUTTypeURL as String])true,所以看起来代码应该有效。

任何想法如何解决这个问题?

编辑1

添加print (url);会打印以下内容。

2017-08-08 14:05:38.917080-0600 _____[1351:289923] [Common] _BSMachError: port 9c0b; (os/kern) invalid capability (0x14) "Unable to insert COPY_SEND"
Optional(<62706c69 73743030 a3010203 5f101a68 74747073 3a2f2f77 77772e6d 61637275 6d6f7273 2e636f6d 2f50d104 05557469 746c655f 10384d61 63205275 6d6f7273 3a204170 706c6520 4d616320 694f5320 52756d6f 72732061 6e64204e 65777320 596f7520 43617265 2041626f 7574080c 292a2d33 00000000 00000101 00000000 00000006 00000000 00000000 00000000 0000006e>)

它还说urlNSSecureCoding?类型。我使用类似的代码进行共享扩展,并且工作正常。

0 个答案:

没有答案