4

我在我的 ios 应用程序中使用 UITableview 和自定义添加和删除行功能。我有该部分的一个标题视图,并且正在使用以下内容设置此视图。

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{

    return tableHeaderView;
}    
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return tableHeaderView.frame.size.height;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;    //count of section
}

我的 uitableview 中只有一个部分。现在,当我从 uitableview 中删除该行并添加另一行时,我面临着问题。我的问题是上面所说的自定义 headerview m 设置。当我更新行(添加或删除行)时,它会移动到底部一段时间,我不知道如何解决这个问题。

谁能指导我,当我删除行并在uitableview中添加一行时,为什么我的部分标题视图会暂时下降?

以下是我正在添加和删除行进程的代码。

-(void)btnHandScanClicked:(UIButton *)sender{       
        CGPoint center= sender.center;
        CGPoint rootViewPoint = [sender.superview convertPoint:center toView:tvChannelPick];
        NSIndexPath *indexPath = [tvChannelPick indexPathForRowAtPoint:rootViewPoint];
        NSLog(@"%ld",(long)indexPath.row);
        TempOrderEntity *tempOrderEnt=[orderArray objectAtIndex:indexPath.row];
        if (tempOrderEnt.orderQuantity>0) {
            tempOrderEnt.orderQuantity--;
        }
        else if(tempOrderEnt.orderQuantity==0){
            TempOrderEntity *orderEntity=[[TempOrderEntity alloc]init];
            orderEntity.orderName=@"30EEK/PAKKING 200";
            orderEntity.orderQuantity=3;
            [orderArray addObject:orderEntity];
           [tvChannelPick insertRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:orderArray.count-1 inSection:0]] withRowAnimation:UITableViewRowAnimationAutomatic];

        }
         [tvChannelPick reloadData];
    }
4

0 回答 0