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


static NSString *CellIdentifier = @"Cell";

HomeVCTableViewCell *cell = (HomeVCTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {

    cell = [[HomeVCTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}

int imageNumber = 0;

for (int i = (indexPath.row * imagesCount); i < ((indexPath.row *imagesCount) + imagesCount); i++) {

        if (i < [cellImageVOArray count]) { // If resultsArray Count is odd then we no need to create cell image

            PhotoVO *photoVo = (PhotoVO *)[cellImageVOArray objectAtIndex:i];

            cell.photobutton.frame=CGRectMake(((imageNumber * 5)+5)+(imageNumber * width), 2, width, height -4);

            cell.photobutton.tag = i + 100;
            [[cell.photobutton layer] setBorderWidth:3.0f];
            [[cell.photobutton layer] setBorderColor:[UIColor whiteColor].CGColor];

            [cell.photobutton addTarget:self action:@selector(imageTapped:) forControlEvents:UIControlEventTouchUpInside];

            [cell.photobutton setBackgroundImageWithURL:[NSURL URLWithString:photoVo.thumb_URL1] placeholderImage:[UIImage imageNamed:@"loader.png"]];
            imageNumber ++;



        }

    }



return cell;

}

CustomCell.m

   - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        // Initialization code

        NSLog(@"Content View = %f",self.contentView.frame.size.height);
        photobutton=[UIButton buttonWithType:UIButtonTypeCustom];
        [self.contentView addSubview:photobutton];



    }
    return self;
}

在上面的代码中,我在每个重复的单元格中只有最后一个按钮,请告诉如何在每个单元格中显示三个按钮提前谢谢

4

1 回答 1

0
 - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
        btn1.frame = CGRectMake(0, 0, 50, 35); // set as u required.
        [self.contentView addSubview:btn1];

        btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
        btn2.frame = CGRectMake(65, 0, 50, 35); // set as u required.
        [self.contentView addSubview:btn2];

        btn3 = [UIButton buttonWithType:UIButtonTypeCustom];
        btn3.frame = CGRectMake(120, 0, 50, 25); // set as u required.
        [self.contentView addSubview:btn3];

    }
    return self;
}
于 2013-03-12T13:32:14.067 回答