我遇到了增加tableView的單元格高度的問題,我在此處使用配置單元格和帶有標記的圖像視圖。雖然我在使用自定義行高的屬性窗格中的故事板上增加了高度,但它不反映在模擬器或設備中。雖然我在故事板上增加UITableViewCell高度,但在設備或模擬器上看不到
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UIButton *detailbtn=[[UIButton alloc]initWithFrame:CGRectMake(230,96, 60, 30)];
[detailbtn addTarget:self action:@selector(yourButtonClicked:) forControlEvents:UIControlEventTouchUpInside]; detailbtn.tag = indexPath.row;
[detailbtn setImage:[UIImage imageNamed:@"btn-detail.png"] forState:UIControlStateNormal];
[cell.contentView addSubview:detailbtn];
UIButton *imageDetailbtn=[[UIButton alloc]initWithFrame:CGRectMake(self.view.frame.origin.x,self.view.frame.origin.y+10,cell.frame.size.width, cell.frame.size.height-100)];
[imageDetailbtn addTarget:self action:@selector(yourButtonClicked:) forControlEvents:UIControlEventTouchUpInside]; imageDetailbtn.tag = indexPath.row;
[imageDetailbtn setImage:[UIImage imageNamed:@"play.png"] forState:UIControlStateHighlighted];
[cell.contentView addSubview:imageDetailbtn];
// [btn setTitle:@"Detail" forState:UIControlStateNormal];
UIButton *likebtn=[[UIButton alloc]initWithFrame:CGRectMake(30,96, 110, 30)];
[likebtn addTarget:self action:@selector(likeButtonClicked:) forControlEvents:UIControlEventTouchUpInside]; likebtn.tag = indexPath.row;
[likebtn setImage:[UIImage imageNamed:@"btn-like.png"] forState:UIControlStateNormal];
NSString *likes = [NSString stringWithFormat:@"%@",[self.devices valueForKey:@"total_likes"]];
[likebtn setTitle:likes forState:UIControlStateNormal];
[cell.contentView addSubview:likebtn];
NSLog(@"sender.tag cell is % ld ",(long)detailbtn.tag);
// Configure Table View Cell
NSLog(@"indexpath is%ld",(long)indexPath.row);
[self configureCell:cell atIndexPath:indexPath];
return cell;
}
- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath
{
// Fetch Record
NSManagedObject *record = [self.fetchedResultsController objectAtIndexPath:indexPath];
// Update Cell
// [cell.textLabel setText:[record valueForKey:@"clip_name"]];
UIImageView* imageView = (UIImageView*)[cell viewWithTag:110];
[imageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",K_Server_imageurl,[record valueForKey:@"clip_image_path"]]]];
UILabel *lbl=(UILabel*)[cell viewWithTag:111];
[lbl setText:[record valueForKey:@"clip_name"]];
lbl.textColor=[UIColor whiteColor];
}
嘗試在 - (float)tableView中設置高度:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {return height_value; } –
@JennyJose但它應該增加高度,如果我增加故事板上的行高。 – vicky
感謝您的答案我會盡力@JennyJose – vicky