Simple way to show the 'Copy' popup on UITableViewCells like the address book App

后端 未结 7 1390
渐次进展
渐次进展 2020-12-12 13:38

Is there a simple way for subclasses of UITableViewCell to show the \'Copy\' UIMenuController popup like in the Address book app (see screenshot), after the selection is hel

相关标签:
7条回答
  • 2020-12-12 14:12

    The method before iOS 5 is to get the UIMenuController's shared instance, set the target rect and view and call -setMenuVisible:animated:. Remeber to implement -canPerformAction:withSender: in your responder.


    The method after iOS 5 (previously available as undocumented feature) is to implement these 3 methods in your data source (see https://developer.apple.com/reference/uikit/uitableviewdelegate#1653389).

    -(void)tableView:(UITableView*)tableView performAction:(SEL)action forRowAtIndexPath:(NSIndexPath*)indexPath withSender:(id)sender;
    -(BOOL)tableView:(UITableView*)tableView canPerformAction:(SEL)action forRowAtIndexPath:(NSIndexPath*)indexPath withSender:(id)sender;
    -(BOOL)tableView:(UITableView*)tableView shouldShowMenuForRowAtIndexPath:(NSIndexPath*)indexPath; 
    
    0 讨论(0)
提交回复
热议问题