- (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;
}
在上面的代码中,我在每个重复的单元格中只有最后一个按钮,请告诉如何在每个单元格中显示三个按钮提前谢谢