首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >UITableView滚动展开的单元格重叠时

UITableView滚动展开的单元格重叠时
EN

Stack Overflow用户
提问于 2013-03-01 13:32:13
回答 1查看 562关注 0票数 0

当滚动uitableview时,展开的单元格被打乱,整个表格单元格被打乱和重叠。为什么会发生这种情况,以及如何设置this.Please指南,提前谢谢。

代码如下:

代码语言:javascript
运行
复制
-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell;

if(tableView == self.mTableView)
{
 cell = [self.mTableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
}

if(tableView == self.mMenuTableView)
{
cell = [self.mMenuTableView dequeueReusableCellWithIdentifier:CellIdentifier];

     if (cell == nil)
     {
         cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
     }
         if(indexPath.section == 0)
         {

             if(!isShowingList)
             {
                 cell.backgroundView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"event_exp.png"]];
             }

             else
             {

                 if(indexPath.row == 0)
                 {
                     cell.backgroundView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"event_exp_active.png"]];
                 }

                 if(indexPath.row == 1)
                 {
                 cell.textLabel.text = [self.mArrSubMenuEvent objectAtIndex:0];
                     cell.backgroundColor = [UIColor colorWithRed:56.0/255.0 green:218.0/255.0 blue:250.0/255.0 alpha:1.0];
                 }
                 if(indexPath.row == 2)
                 {
                     cell.textLabel.text = [self.mArrSubMenuEvent objectAtIndex:1];

                 }
                 if(indexPath.row == 3)
                 {
                     cell.textLabel.text = [self.mArrSubMenuEvent objectAtIndex:2];
                }

             }

         }

         if(indexPath.section == 1)
         {

             if(!isOverhead)
             {
                 cell.backgroundView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"overhead_exp.png"]];
             }
             else
             {
             if(indexPath.row == 0)
             {

             cell.backgroundView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"overhead_exp_active.png"]];

             }

             if(indexPath.row == 1)
             {
                 cell.textLabel.text = @"Friend";
             }

             if(indexPath.row == 2)
             {
                 cell.textLabel.text = @"Public";
             }

             }

         }

         if(indexPath.section == 2)
         {

             NSString *imgName = [self.mArrCellImages objectAtIndex:indexPath.row];
             cell.backgroundView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:imgName]];
         }

     }

cell.selectionStyle = UITableViewCellSelectionStyleNone;

return cell;
}
EN

Stack Overflow用户

回答已采纳

发布于 2013-03-01 13:41:35

将reuseIdentifier设置为nil。

代码语言:javascript
运行
复制
cell = [self.mTableView dequeueReusableCellWithIdentifier:nil];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
    }
票数 3
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15151187

复制
相关文章

相似问题

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