gpt4 book ai didi

ios - 在reloadData Xcode的同时,在表格末尾插入新的自定义行

转载 作者:行者123 更新时间:2023-12-01 18:48:04 26 4
gpt4 key购买 nike

坦白说,我知道如何在不使用reloadData的情况下插入表格的新自定义行末尾,但是现在我想知道如何在reloadData的同时插入UITable的新自定义行末尾。

这是我的代码,在reloadData时插入新的自定义行。但是新插入的行出现在表格的顶部,这不是我想要的。

    CoachPadItem *newCoachPadItem = [[CoachPadItem alloc]init];
newCoachPadItem.coachpadDescription = textView.text;
newCoachPadItem.coachpadTagId = @"0";
[_tagPointsArray addObject:newCoachPadItem];
[_coachpadTableView reloadData];

cellforrowatindexpath
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

// Configure the cell...
CoachPadPointCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CoachPadPointCell" forIndexPath:indexPath];

if (cell == nil) {
cell = [[CoachPadPointCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CoachPadPointCell"];
}

counter += 1;

cell.tagBtn.hidden = YES;
cell.btnRemove.hidden = YES;

cell.tagBtn.userInteractionEnabled = canEdit;
[cell.tagBtn addTarget:self action:@selector(removeTag:) forControlEvents:UIControlEventTouchUpInside];
[cell.btnRemove addTarget:self action:@selector(removePad:) forControlEvents:UIControlEventTouchUpInside];
cell.btnRemove.tag = counter;
cell.txtPoint.delegate = self;
cell.txtPoint.tag = counter;
cell.txtPoint.textContainer.maximumNumberOfLines = 2;
cell.tagBtn.tag = counter;
cell.txtPoint.textAlignment = NSTextAlignmentLeft;
cell.txtPoint.backgroundColor = [UIColor clearColor];
cell.txtPoint.userInteractionEnabled = canEdit;

cell.backgroundColor = [UIColor clearColor];
cell.selectionStyle = UITableViewCellSelectionStyleNone;

CoachPadItem *curr = _tagPointsArray[indexPath.row];
cell.txtPoint.text = cure.MyDesc;

return cell;
}

请帮助我如何将新行放在UITable的末尾?

最佳答案

我不确定会发生什么。

但是,如果[_tagPointsArray addObject:newCoachPadItem];导致新插入的行出现在表的顶部,这不是我想要的,则可以尝试:

[_tagPointsArray insertObject: newCoachPadItem atIndex:0];

关于ios - 在reloadData Xcode的同时,在表格末尾插入新的自定义行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33359550/

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