iOS 11丢弃url返回无
我有以下代码,我试图将一个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()
它还说url
是NSSecureCoding?
类型NSSecureCoding?
。 我使用类似的代码进行共享扩展,并且工作正常。