我在執行允許文本換行到多行的表格行時遇到問題,並且在左側有一個圖像,在右側有一個公開accesssory。在多行表格行中停止圖像展開?
多行文本很好,但當有多行文本時,imageView向右擴展。我希望所有行中的圖像具有相同的大小。我已經嘗試將autoresizingMask設置爲UIViewAutoresizingNone,但這似乎不工作..我是否需要使用contentView或nib文件?
任何幫助/示例代碼讚賞!
我在執行允許文本換行到多行的表格行時遇到問題,並且在左側有一個圖像,在右側有一個公開accesssory。在多行表格行中停止圖像展開?
多行文本很好,但當有多行文本時,imageView向右擴展。我希望所有行中的圖像具有相同的大小。我已經嘗試將autoresizingMask設置爲UIViewAutoresizingNone,但這似乎不工作..我是否需要使用contentView或nib文件?
任何幫助/示例代碼讚賞!
如果所有的圖像都是不同的大小,那麼你應該考慮添加一個ImageView作爲子視圖到單元格。根據Imageview保留標籤。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell;
UIImageView *cellImage;
UILabel *label;
UILabel *detailLabel;
cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; //Create cell
if(cell == nil)
{
cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"] autorelease];
cellImage = [[[UIImageView alloc] initWithFrame:CGRectMake(3, 3, 44, 44)] autorelease];
label = [[[UILabel alloc] initWithFrame:CGRectMake(55, 4, 260, 20)] autorelease];
label.font = [UIFont boldSystemFontOfSize:15.0];
label.tag=25;
detailLabel = [[[UILabel alloc] initWithFrame:CGRectMake(55, 25, 260, 15)] autorelease];
detailLabel.font = [UIFont systemFontOfSize:13.0];
detailLabel.tag=30;
[cell.contentView addSubview:cellImage];
[cell.contentView addSubview:label];
[cell.contentView addSubview:detailLabel];
cell.accessoryType =UITableViewCellAccessoryDisclosureIndicator;
}
else
{
cellImage = (UIImageView *)[cell.contentView viewWithTag:20];
label = (UILabel *)[cell.contentView viewWithTag:25];
detailLabel = (UILabel *)[cell.contentView viewWithTag:30];
}
cell.image = [arrayContainingImages objectAtIndex:indexPath.row];
label.text =[arrayContaininglabeltext objectAtIndex:indexPath.row];
detailLabel.text=[arrayContainingDetailLabelText objectAtIndex:indexPath.row];
return cell;
}
您使用的UITableViewCell或自定義單元格上顯示的tableview? – iMOBDEV