【发布时间】:2011-03-09 00:40:29
【问题描述】:
我创建了一个表格,在分配的图像旁边显示一些用户输入(有点像 Facebook 应用程序上的墙贴)。但是,默认对齐方式是沿单元格的高度居中。我希望默认对齐位于左上角。有没有办法在不创建自定义单元格的情况下做到这一点?这是我的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.textLabel.numberOfLines = 0;
cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:12.0];
}
// Configure the cell.
[[cell imageView] setImage:[UIImage imageNamed:[[[userData objectAtIndex:indexPath.section] objectAtIndex: indexPath.row] objectForKey:@"picture"]]];
[[cell textLabel] setText:[[[userData objectAtIndex:indexPath.section] objectAtIndex: indexPath.row] objectForKey:@"post"]];
return cell;
}
谢谢!
【问题讨论】:
标签: cocoa-touch ios uitableview uiimageview