gpt4 book ai didi

ios - 在 UITableView 中一次只允许选中一行,保留动画

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

我想制作一个 UITableView 来选择选项(一次一个复选标记附件),就像在“设置”应用程序中一样(例如,选择笔记的字体)。

我一直在阅读其他线程,确保我在 cellForIndexPath 方法中重置了附件类型,并且我在 中执行了 deselectCell... didSelect... 方法。但是,我只能使用 [tableView reloadData] 来“刷新”表格。

不幸的是,这取消/缩短了 [tableView deselectRowAtIndexPath: animated:] 方法。有什么方法可以实现这一点,而无需遍历所有行的原始循环吗?

最佳答案

尝试这样的事情:

- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// In cellForRow... we check this variable to decide where we put the checkmark
self.checkmarkedRow = indexPath.row;

// We reload the table view and the selected row will be checkmarked
[tableView reloadData];

// We select the row without animation to simulate that nothing happened here :)
[tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];

// We deselect the row with animation
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}

关于ios - 在 UITableView 中一次只允许选中一行,保留动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17055337/

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