UITableView Section Header View Position Changes on Reloading Table

855 views Asked by At

i am using UITableview in my ios Application with the custom add and delete row functionality. i have one headerview for the section and am setting this view with the following.

- (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
}

i have only one section in my uitableview. now problem am facing when am deleting the row from uitableview and adding one another row. my problem is that the custom headerview m setting as said above.its move to bottom for a while when i update the rows (adding or deleting row) i dont know how to solve this problem.

can anyone please guide me that why my headerview of section comes to bottom for a while when m deleting the row and adding one row in uitableview?

following is my code where am doing adding and deleting row prcess.

-(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];
    }
0

There are 0 answers