【发布时间】:2011-11-04 01:47:55
【问题描述】:
过去几天我一直在玩 tableviews 试图习惯它们,今天我一直在尝试创建一个自定义的 uitableviewcell,我正在根据苹果文档中的 Table View Programming Guide 工作并且有这个奇怪我正在尝试做的事情有问题。
我已经设置了一个自定义单元笔尖文件,它上面有两个标签,都有标签(0 和 1)我已经将文件所有者类更改为将使用它的笔尖。
从那里我开始编写 tableView:cellForRowAtIndexPath: 方法,该方法在 tableview 中显示我的自定义单元格,但是如您所见,当我为其分配一个字符串时,只有我的第一个标签显示,我只是不知道为什么。 ..
自定义单元笔尖
tableView:cellForRowAtIndexPath: 方法
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
//cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] autorelease];
[[NSBundle mainBundle] loadNibNamed:@"ManufactureSearchCell" owner:self options:nil];
cell = vehicleSearchCell;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
self.vehicleSearchCell = nil;
}
// Configure the cell...
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if(indexPath.section == 0)
{
if(indexPath.row == 0)
{
UILabel *label;
label = (UILabel *)[cell viewWithTag:0];
label.text = [[NSString alloc] initWithString:@"Manufacture :"];
label = (UILabel *)[cell viewWithTag:1];
label.text = [[NSString alloc] initWithString:@"empty"];
}
else if(indexPath.row == 1)
{
//.....
任何帮助将不胜感激:)
【问题讨论】:
标签: iphone ios uitableview uilabel