gpt4 book ai didi

ios - 长按表格 View 单元格以打开选项

转载 作者:行者123 更新时间:2023-11-29 11:05:27 25 4
gpt4 key购买 nike

可以在“通讯录”应用中找到此行为。

如果您长按联系人页面中的表格行,“复制”选项会在该行的顶部弹出。我怎样才能在我自己的表格 View 单元格中获得这种行为。

最佳答案

如果您使用的是 iOS 5.0 或更高版本,您可以使用默认行为:

- (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:)) {
[UIPasteboard generalPasteboard].string = @"test";
}
}

关于ios - 长按表格 View 单元格以打开选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13836492/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com