gpt4 book ai didi

iphone - 无法在 UITableView 中为 UITableViewCellAccessoryCheckmark 选择单元格

转载 作者:行者123 更新时间:2023-11-29 11:09:26 24 4
gpt4 key购买 nike

如果您在 iOS 中使用过消息应用程序,您就会知道我们如何通过编辑按钮在任何消息中调用 UITableViewCellAccessoryCheckmark,然后选择每个气泡/单元格以用于转发或删除目的。

我正在尝试在我的应用程序中做同样的事情。我可以点击编辑并显示 UITableViewCellAcessoryCheckMark,但我无法选择使用它的单元格。我还需要实现什么?

enter image description here

如有任何帮助,我们将不胜感激。这是代码-

- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellAccessoryCheckmark;
}

最佳答案

对于如图所示的表格 View ,其中一个或多个单元格可以用复选标记符号选择,您必须在表格 View 上设置 allowsMultipleSelectionDuringEditing = YES。这可以在 viewDidLoad 中用

完成
self.tableView.allowsMultipleSelectionDuringEditing = YES

或在 NIB/Storyboard 文件的 TableView 的属性检查器中,通过将“编辑”设置为“编辑期间的多项选择”。

为此不需要 tableView:editingStyleForRowAtIndexPath: 方法。

(顺便说一下,您的方法返回 UITableViewCellAccessoryCheckmark,它是 UITableViewCellAccessoryType 而不是 UITableViewCellEditingStyle。)

关于iphone - 无法在 UITableView 中为 UITableViewCellAccessoryCheckmark 选择单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12204492/

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