我正在尝试为我的项目修复所有警告,但似乎无法弄清楚该如何做。
我得到的警告是:
iOS 13.0中不推荐使用“ sourceView”:重命名为“ UIContextMenuInteraction”
这是它正在谈论的代码:
extension CollectionsViewController: UIViewControllerPreviewingDelegate {
func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
let tableView = previewingContext.sourceView as! UITableView
if let indexPath = tableView.indexPathForRow(at: location) {
let cell = tableView.cellForRow(at: indexPath) as! CollectionCell
let touch = cell.convert(location, from: tableView)
if let productResult = cell.productFor(touch) {
previewingContext.sourceRect = tableView.convert(productResult.sourceRect, from: cell)
return self.productDetailsViewControllerWith(productResult.model)
} else if let collectionResult = cell.collectionFor(touch) {
previewingContext.sourceRect = tableView.convert(collectionResult.sourceRect, from: cell)
return self.productsViewControllerWith(collectionResult.model)
}
}
return nil
}
func previewingContext(_ previewingContext: UIViewControllerPreviewing, commit viewControllerToCommit: UIViewController) {
self.navigationController!.show(viewControllerToCommit, sender: self)
}
}
任何帮助将不胜感激!
UIViewControllerPreviewingDelegate协议已按以下说明进行了更改:
不推荐使用UseUIContextMenuInteractionDelegate。
因此,您需要删除previewingContext
委托方法,而不是更改其参数sourceview等。代替此方法,您需要从UIContextMenuInteractionDelegate
Apple指示的委托方法的新协议中选择。
换句话说,您的扩展名已完全过时,您需要根据新协议进行重写。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句