iOS方式开始向下滚动时,Checkmark消失 [英] iOS Way the Checkmark disappears when begin scroll down
本文介绍了iOS方式开始向下滚动时,Checkmark消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
勾选标记在开始向下滚动时消失。
Way the Checkmark disappears when begin scroll down.
下面是 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 ;
}
}
}
有什么问题吗?或者是否有任何其他技术。
Is there any problem ? or if there any other technique.
推荐答案
尝试这个来存储复选标记单元格数据。并希望这可以解决您的问题:
Try this one to store checkmark cell data.And hope this solves your problem:
- (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方式开始向下滚动时,Checkmark消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文