I have a view with three collection views on it. I want one of the collection views to have a contextual menu. How do I control that only one of them has the menu? In the code below, I have commented out the lines that I'm trying to use to restrict which collection view has the menu.
If I uncomment these lines and try to restricted the menu to just the list_CollectionView_Outlet, I get the error that it's missing a return. "Missing return in instance method expected to return 'UIContextMenuConfiguration?'
It's driving me bonkers what am I doing wrong?
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
// }
}
}
At the start, where those two commented-out lines are, check that you have the right collection view like this:
guard collectionView == list_CollectionView_Outlet else {
return nil
}