Saturday, July 27, 2024
HomeiOS Developmentios - Easy methods to limit a contextual menu to a single...

ios – Easy methods to limit a contextual menu to a single collectionView


I’ve a view with three assortment views on it. I need one of many assortment views to have a contextual menu. How do I management that solely one in every of them has the menu? Within the code beneath, I’ve commented out the traces that I am attempting to make use of to limit which assortment view has the menu.

If I uncomment these traces 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 fallacious?

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].Identify
        
        let configuration = UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { [weak self] _ in
            
            let edit = UIAction(title: Okay.Titles.edit, picture: UIImage(named: "Edit2")) { _ in
                gHideBackBtn = false
                gTheDisabledCell = ""
                self?.addEditTrick()
            }
            
            let take away = UIAction(title: Okay.Titles.take away, picture: UIImage(systemName: Okay.Icons.trash)) { _ in
                self?.delete_XRef_Item()
            }
            
            return UIMenu(title: "", picture: nil, youngsters: [edit, remove])
        }
        
        return configuration
        //    }
    }
}



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments