gpt4 book ai didi

ios - 开始向下滚动时,iOS方法的复选标记消失

转载 作者:行者123 更新时间:2023-12-01 19:18:36 24 4
gpt4 key购买 nike

开始向下滚动时Checkmark消失的方式。

这是didSelectRowAtIndexPath方法的代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];

if (selectedCell.accessoryType == UITableViewCellAccessoryCheckmark) {
selectedCell.accessoryType = UITableViewCellAccessoryNone;

if ([[[collectionDataArray objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] objectForKey:@"creditHours"]==@"1") {
totalHoure = totalHoure - 1;
}

} else {

selectedCell.accessoryType = UITableViewCellAccessoryCheckmark;

if ([[[collectionDataArray objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] objectForKey:@"creditHours"]==@"1") {
totalHoure = totalHoure + 1 ;
}
}
}

有什么问题吗 ?或是否有其他技巧。

最佳答案

试试这个来存储选中标记单元格数据,并希望这可以解决您的问题:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];

if ([selectedCell accessoryType] == UITableViewCellAccessoryNone || [selectedCell accessoryType]== UITableViewCellAccessoryDisclosureIndicator)
{
[selectedCell setAccessoryType:UITableViewCellAccessoryCheckmark];
[Mybuffer addObject:[arrItem objectAtIndex:indexPath.row]];
}
else
{
[selectedCell setAccessoryType:UITableViewCellAccessoryNone];
[Mybuffer removeObject:[NSNumber numberWithInt:indexPath.row]];
}
}

关于ios - 开始向下滚动时,iOS方法的复选标记消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11462377/

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