首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >我有一个问题,当我滚动我的表视图时,数据不是按照数组显示的,而是显示较旧的单元格数据

我有一个问题,当我滚动我的表视图时,数据不是按照数组显示的,而是显示较旧的单元格数据
EN

Stack Overflow用户
提问于 2017-04-17 17:33:49
回答 1查看 48关注 0票数 1

我有一个问题,当我滚动UITableView时,它第一次显示两行之后,当我滚动到第三行时,它再次在第三行显示第一行数据。

我使用了以下代码:

代码语言:javascript
运行
复制
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....
        }

我的代码中有什么错误吗?

EN

回答 1

Stack Overflow用户

发布于 2017-04-17 19:02:14

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

代码语言:javascript
运行
复制
- (NSInteger)tableView:(UITableView *)tableView 
             numberOfRowsInSection:(NSInteger)section


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

这也是一个很好的this on AppCoda教程

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43448834

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档