Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/100.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 目标C:如何实施ABTableViewCell?_Objective C_Ios_Uitableview - Fatal编程技术网

Objective c 目标C:如何实施ABTableViewCell?

Objective c 目标C:如何实施ABTableViewCell?,objective-c,ios,uitableview,Objective C,Ios,Uitableview,我的UITableView当前面临严重的滚动性能问题。我的自定义单元格中有以下子视图 1 X UIImageView 2个UILabel 3个UI按钮 我在网上读到,在一个自定义单元格中有多个子视图将对滚动性能产生严重影响。我找到了ABTableViewCell,但不确定如何将当前代码移植到它 我当前代码的片段 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)

我的UITableView当前面临严重的滚动性能问题。我的自定义单元格中有以下子视图

  • 1 X UIImageView
  • 2个UILabel
  • 3个UI按钮
  • 我在网上读到,在一个自定义单元格中有多个子视图将对滚动性能产生严重影响。我找到了ABTableViewCell,但不确定如何将当前代码移植到它

    我当前代码的片段

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString* PlaceholderCellIdentifier = @"PlaceholderCell";
        int row = [indexPath row];
        SomeClass *thisClass = [self.someClassArray objectAtIndex:row];
    
        CustomCell* cell = (CustomCell*)[tableView dequeueReusableCellWithIdentifier:PlaceholderCellIdentifier];
        if (cell == nil)
        {
            cell = [[[CustomCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:PlaceholderCellIdentifier] autorelease]; 
    
        //Set Avatar imageview
        UIImageView *avatarView = [[UIImageView alloc]initWithFrame:CGRectMake(5, CELL_SPACING,CELL_AVATAR_WIDTH, CELL_AVATAR_HEIGHT)];
        avatarView.tag = 1;
    
        //Set text Label
    
        UILabel *textLabel = [[UILabel alloc]initWithFrame:CGRectZero];
        textLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:13.0];
        [textLabel setLineBreakMode:UILineBreakModeWordWrap];
        textLabel.numberOfLines = 0;
    
        textLabel.tag = 2;
    
    
        //Add button1
        UICustomButton *button = [[UICustomButton alloc]init];
        button.tag = 3;
    
    
        [self.contentView addSubview:avatarView];
        [self.contentView addSubview:textlabel];
        [self.contentView addSubview:button];
    
    
    }
    
     //Set Avatar imageview
     UIImageView *thisAvatarView = (UIImageView *)[self.contentView viewWithTag:1];
     thisAvatarView.image = self.dataForCell.user.avatar;
    
     //Set data to text Label
     NSString *text = [NSString stringWithFormat:@"%@",self.dataForCell.text];
     CGFloat answerLabelHeight = [CustomCell getHeightOfLabel:self.dataForCell ofType:@"XXX"];
    
     UILabel *thisTextLabel = (UILabel*)[self.contentView viewWithTag:2];
     [thisTextLabel setFrame:CGRectMake(CELL_TEXT_LEFT_MARGIN, CELL_SPACING+CELL_USERNAMELABEL_HEIGHT+questionLabelheight,CELL_CONTENT_WIDTH - CELL_TEXT_LEFT_MARGIN*1.5, answerLabelHeight)];
    
     thisTextLabel.text = someData;
    
     //Set data to button
     UICustomButton *thisButton = (UICustomButton *)[self.contentView viewWithTag:3];
     [thisButton setButtonWithAnswer:self.dataForCell buttonType:@"like" navcon:self.navcon andFrame:CGRectMake(CELL_TEXT_LEFT_MARGIN, totalCommentLabelHeight + CELL_SPACING*4, 45, CELL_BUTTON_HEIGHT)];
     thisLikeButton.imageView.image = [UIImage imageNamed:@"xxxx.png"];
    
    }


    很抱歉代码太长,但有谁能指导我如何开始使用ABTableViewCell进行此实现?

    今年WWDC上有一个关于优化UITableViewCells的非常好的演示,如果您有权使用它们(是一名注册的苹果开发者),我建议您查看。@stephen-j感谢您的提示。你推荐哪一个?我注意到2个似乎相关的问题:iOS的深度性能和iOS 5的实用技巧。