【发布时间】:2012-09-08 12:56:34
【问题描述】:
如何添加如下截图所示的图像和文本?我已经在我的应用程序中使用导航控制器,所以将 UITableView 控制器作为主页中的新导航页面包含任何问题。
【问题讨论】:
标签: ios ios4 xcode4 uitableview
如何添加如下截图所示的图像和文本?我已经在我的应用程序中使用导航控制器,所以将 UITableView 控制器作为主页中的新导航页面包含任何问题。
【问题讨论】:
标签: ios ios4 xcode4 uitableview
在配置UITableViewCell时,您可以将UIImageView 和UILabel 添加到单元格contentView。
UITableViewCell *cell = ...;
UIImageView *yourImageView = ...;
UILabel *yourLabel = ...;
[cell.contentView addSubview:yourImageView];
[cell.contentView addSubview:yourLabel];
【讨论】:
我将继承 UITableView 单元并创建自己的单元MyCustomTableViewCell,其中包含 UIImageView 和 UILabel。
然后您可以这样做以更新您的单元格以重用案例
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]
MyCustomTableViewCell *myCell = (MyCustomTableViewCell)cell;
myCell.label.text = newText;
myCell.imageView.image = newImage;
return cell;
}
【讨论】: