ios - How to show MenuController of UICollectionViewCell? -


how reproduce copy paste function of say, messages on iphone, if long press on message, message cell goes gray-ish , little pop-up "copy" shows up. how can show same menu on uicollectionviewcells?

as turns out functionality built in , simple implementing 3 collectionview: delegate methods. created protocol copyablecell property called copyableproperty, string cell wants copy clipboard, cells can copy must follow. straightforward on:

  func collectionview(collectionview: uicollectionview, shouldshowmenuforitematindexpath indexpath: nsindexpath) -> bool {     if let _ = collectionview.cellforitematindexpath(indexpath) as? copyablecell {       return true     }     return false   }   func collectionview(collectionview: uicollectionview, canperformaction action: selector, foritematindexpath indexpath: nsindexpath, withsender sender: anyobject?) -> bool {     if action.description == "copy:" {       return true     }      return false   }    func collectionview(collectionview: uicollectionview, performaction action: selector, foritematindexpath indexpath: nsindexpath, withsender sender: anyobject?) {     //no more checking needed here since allow copying     if let cell = collectionview.cellforitematindexpath(indexpath) as? copyablecell {       uipasteboard.generalpasteboard().string = cell.copyableproperty     }   } 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -