gpt4 book ai didi

ios - iOS 11 之前的行操作

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

我正在尝试向表格 View 中的一行添加一个 Action (通过滑动)。由于缺陷,我可以使用此方法删除:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
}

但我不知道如何进行自定义操作。我读到他们在 iOS 11 中引入了它。如果我也需要它用于以前的版本怎么办?

这是 iOS 11 的方法:

- (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath

如您所见,我使用的是 iOS 11。所以,为了清楚起见,我希望用户滑动一行以显示一个 Action (具有不同颜色的背景和文本)。我不关心它出现的形式(尾随或前导)。

最佳答案

So, to make it clear, I want the user to swipe a row to show an action (with different color background and a text). I don't care form where it appears (trailing or leading).

这样做

-(NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath{

UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@" Delete " handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
// your delete mechanism here
}];
deleteAction.backgroundColor = [UIColor redColor];
return @[deleteAction];

}

关于ios - iOS 11 之前的行操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48784515/

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