在UITableViewCells上显示“复制”弹出窗口的简单方法,如地址簿App [英] Simple way to show the 'Copy' popup on UITableViewCells like the address book App
问题描述
UITableViewCell的子类是否有一种简单的方法可以在选择保留一段时间之后显示复制UIMenuController弹出窗口,如地址簿应用程序(参见屏幕截图)?
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 held for a while?
推荐答案
iOS 5之前的方法是获取UIMenuController的共享实例,设置目标rect并查看并调用 -setMenuVisible:animated:
。记得在你的响应者中实现 -canPerformAction:withSender:
。
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.
iOS 5之后的方法(以前作为未记录的功能提供)是在数据源中实现这3种方法(参见 https://developer.apple.com/reference/uikit/uitableviewdelegate#1653389 。
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;
这篇关于在UITableViewCells上显示“复制”弹出窗口的简单方法,如地址簿App的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!