UITableView 需要长按显示系统菜单

在实现系统提示菜单时,一般用户的行为是,长按给出系统提示菜单


下例子为长按弹出系统复制菜单,并给予实现

- (BOOL) tableView:(UITableView *)tableView shouldShowMenuForRowAtIndexPath:(NSIndexPath *)indexPath

{

return YES;

}

- (BOOL) tableView:(UITableView *)tableView canPerformAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender

{

if (action == @selector(copy:)) {

return YES;

}

return NO;

}

- (void) tableView:(UITableView *)tableView performAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender

{

if (action == @selector(copy:)) {

UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

UIPasteboard *pasteBorad = [UIPasteboard generalPasteboard];

[pasteBorad setString:cell.textLabel.text];

}

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • #pragma mark someValueAboutTableView 1.tableView的样式:UITab...
    潇岩阅读 4,565评论 0 0
  • 1、禁止手机睡眠[UIApplication sharedApplication].idleTimerDisabl...
    DingGa阅读 4,811评论 1 6
  • 概述在iOS开发中UITableView可以说是使用最广泛的控件,我们平时使用的软件中到处都可以看到它的影子,类似...
    liudhkk阅读 12,959评论 3 38
  • 一、活动目标: 通过活动培养学生读书、爱书的好习惯,为他们今后的成长及终身学习提供文化底蕴。 通过活动在...
    浅浅嘚愛阅读 1,280评论 0 0
  • 多年前 我买了一个粉色洗脸盆 因为里面有一只可爱的小老鼠 一个小女孩指着自己的脸 对小老鼠说,亲亲我 小老鼠踮起脚...
    温宇荷阅读 1,677评论 0 0