- (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;
}
上記のコードでは、繰り返していたすべてのセルでセルの最後のボタンのみを取得しました 各セルに3つのボタンを表示する方法を教えてください よろしくお願いします