我有一个视图,上面有三个集合视图。我希望其中一个集合视图有一个上下文菜单。我如何控制其中只有一个有菜单?在下面的代码中,我已经注释掉了我试图用来限制哪个集合视图有菜单的行。
如果我取消注释这些行,并尝试将菜单限制为list_CollectionView_Outlet,我会得到一个错误,即它缺少返回值。“实例方法中缺少预期返回'UIContextMenuConfiguration?'的返回值
我快疯了,我做错了什么?
extension Case_VC2: UICollectionViewDelegate
{
func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration?
{
// if collectionView == list_CollectionView_Outlet
// {
gID = theCurrentArray[indexPath.row].ID
name = theCurrentArray[indexPath.row].Name
let configuration = UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { [weak self] _ in
let edit = UIAction(title: K.Titles.edit, image: UIImage(named: "Edit2")) { _ in
gHideBackBtn = false
gTheDisabledCell = ""
self?.addEditTrick()
}
let remove = UIAction(title: K.Titles.remove, image: UIImage(systemName: K.Icons.trash)) { _ in
self?.delete_XRef_Item()
}
return UIMenu(title: "", image: nil, children: [edit, remove])
}
return configuration
// }
}
}