Ios 我有一个问题,当我滚动我的表视图数据时,它并没有根据数组显示旧的单元格数据

Ios 我有一个问题,当我滚动我的表视图数据时,它并没有根据数组显示旧的单元格数据,ios,objective-c,uitableview,nsarray,Ios,Objective C,Uitableview,Nsarray,当我滚动UITableView时出现问题,当我在第三行滚动时,它第一次显示两行,然后在第三行再次显示第一行数据 我使用了以下代码: static NSString *CellIdentifier = @"inviCell1"; inviProfileCell *cell1 = (inviProfileCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; cell1.

当我滚动
UITableView
时出现问题,当我在第三行滚动时,它第一次显示两行,然后在第三行再次显示第一行数据

我使用了以下代码:

static NSString *CellIdentifier = @"inviCell1";

        inviProfileCell *cell1 =
        (inviProfileCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        cell1.selectionStyle = UITableViewCellSelectionStyleNone;

        if(cell1 == nil) {
            cell1 = [[inviProfileCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] ;

        }

      Obj=[[ObjClass alloc]init];

      Obj=[fetchedArray objectAtIndex:0];

        UIButton *btn1 = (UIButton *)[cell1 viewWithTag:101];
        UIButton *btn2 = (UIButton *)[cell1 viewWithTag:102];
        UIButton *btn3 = (UIButton *)[cell1 viewWithTag:103];
        UIButton *btn4 = (UIButton *)[cell1 viewWithTag:104];
        UIButton *btn5 = (UIButton *)[cell1 viewWithTag:105];
        UIButton *btn6 = (UIButton *)[cell1 viewWithTag:106];

        cell1.moreBtn.tag = indexPath.row+1;
        cell1.moreBtn.userInteractionEnabled = YES;
        if (inviLoadCount > indexPath.row+1) {
            cell1.moreBtn.hidden = YES;
        }else{
            cell1.moreBtn.hidden = NO;
        }

        int maxindex = (int)(6*(indexPath.row+1));
        int startIndex = (int)(6*indexPath.row);
        int counter = 1;

        NSLog(@"%lu",(unsigned long)boast_Obj.purchase_array.count);
        for (int i = startIndex; i < maxindex; i++) {                
       //  functionality....
        }
静态NSString*CellIdentifier=@“inviCell1”;
第1单元*1单元=
(inviProfileCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell1.selectionStyle=UITableViewCellSelectionStyleNone;
if(cell1==nil){
cell1=[[inviProfileCell alloc]initWithStyle:UITableViewCellStyleDefault重用标识符:CellIdentifier];
}
Obj=[[ObjClass alloc]init];
Obj=[fetchedArray对象索引:0];
UIButton*btn1=(UIButton*)[cell1视图带标签:101];
UIButton*btn2=(UIButton*)[cell1视图带标签:102];
UIButton*btn3=(UIButton*)[cell1视图带标签:103];
UIButton*btn4=(UIButton*)[cell1视图带标记:104];
UIButton*btn5=(UIButton*)[cell1视图带标签:105];
UIButton*btn6=(UIButton*)[cell1视图带标签:106];
cell1.moreBtn.tag=indexPath.row+1;
cell1.moreBtn.userInteractionEnabled=是;
if(invioadcount>indexPath.row+1){
cell1.moreBtn.hidden=是;
}否则{
cell1.moreBtn.hidden=否;
}
intmaxindex=(int)(6*(indexPath.row+1));
int startIndex=(int)(6*indexPath.row);
int计数器=1;
NSLog(@“%lu”,(无符号长)具有对象购买和数组计数);
对于(inti=startIndex;i

我的代码有什么错误吗?

不完全清楚在你的整个班级中实现了
UITableView
的哪些方法。您至少应该有两种重要的方法:

- (NSInteger)tableView:(UITableView *)tableView 
             numberOfRowsInSection:(NSInteger)section


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

这也是一个很好的教程,可以帮助您了解在整个课程中实现了哪些
UITableView
方法。您至少应该有两种重要的方法:

- (NSInteger)tableView:(UITableView *)tableView 
             numberOfRowsInSection:(NSInteger)section


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

这里还有一个很好的教程,介绍添加
numberOfRows
方法。-(NSInteger)tableView:(UITableView*)tableView numberofrowsinssection:(NSInteger)section{if([tableView isEqual:_inviTableView]){return invioadcount;}你的行是固定的还是会改变计数。它不是根据某些条件固定的。还有一件事。我在第一次显示单行之后,当我单击单元格中有一个按钮时,它会重新加载表并获取数据(如果是moe),然后是一个…每次我单击该按钮时,表都会重新加载..当我看到一个
for
循环时
cellForRow(位于:)
这是一种代码气味。当表格滚动时,此方法将被指定行多次调用,并且不会按行顺序调用。使用视图
标记
s也是一个坏主意。将属性添加到
UITableViewCell
类中,以便您可以直接访问视图。此外,按照惯例,类名应以大写字母。添加
numberOfRows
方法。-(NSInteger)tableView:(UITableView*)tableView numberofrowsinssection:(NSInteger)节{if([tableView isEqual:_inviTableView]){返回invioadcount;}你的行是固定的还是会改变计数。它不是根据某些条件固定的。还有一件事。我在第一次显示单行之后,当我单击单元格中有一个按钮时,它会重新加载表并获取数据(如果是moe),然后是一个…每次我单击该按钮时,表都会重新加载..当我看到一个
for
循环时
cellForRow(位于:)
这是一种代码气味。当表格滚动时,此方法将被指定行多次调用,并且不会按行顺序调用。使用视图
标记
s也是一个坏主意。将属性添加到
UITableViewCell
类中,以便您可以直接访问视图。此外,按照惯例,类名应以大写字母。