Thursday, September 11, 2025
HomeiOS Developmentios - Methods to prohibit a contextual menu to a single collectionView

ios – Methods to prohibit a contextual menu to a single collectionView


I’ve a view with three assortment views on it. I would like one of many assortment views to have a contextual menu. How do I management that solely one among them has the menu? Within the code under, I’ve commented out the strains that I am making an attempt to make use of to limit which assortment view has the menu.

If I uncomment these strains and attempt to restricted the menu to simply the list_CollectionView_Outlet, I get the error that it is lacking a return. “Lacking return in occasion technique anticipated to return ‘UIContextMenuConfiguration?’

It is driving me bonkers what am I doing flawed?

extension Case_VC2: UICollectionViewDelegate
{
    func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, level: CGPoint) -> UIContextMenuConfiguration?
    {
        //        if collectionView == list_CollectionView_Outlet
        //        {
        gID = theCurrentArray[indexPath.row].ID
        title = theCurrentArray[indexPath.row].Title
        
        let configuration = UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { [weak self] _ in
            
            let edit = UIAction(title: Ok.Titles.edit, picture: UIImage(named: "Edit2")) { _ in
                gHideBackBtn = false
                gTheDisabledCell = ""
                self?.addEditTrick()
            }
            
            let take away = UIAction(title: Ok.Titles.take away, picture: UIImage(systemName: Ok.Icons.trash)) { _ in
                self?.delete_XRef_Item()
            }
            
            return UIMenu(title: "", picture: nil, youngsters: [edit, remove])
        }
        
        return configuration
        //    }
    }
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments