-viewDidLoad {
tbl.rowHeight = 150;
ary = [[NSArray alloc]initWithObjects:@"asdf",@"asd",nil];
ary2 = [[NSArray alloc]initWithObjects:@"google",@"yahoo",nil];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [ary count];
}
// Customize the appearance of table view cells.
- (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];
}
// Configure the cell.
cell.textLabel.text = [ary objectAtIndex:indexPath.row];
cell.detailTextLabel.text = [ary2 objectAtIndex:indexPath.row] ;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}我的问题是detailtextlabel不能在表视图中显示。我的代码中有没有什么错误?
发布于 2011-04-07 15:05:39
发布于 2011-04-07 14:57:46
您必须将单元格styleSubtitle设置为副标题,如下所示
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];发布于 2011-04-07 14:58:04
确保您使用的是UITableViewCellStyle anything,而不是UITableViewCellStyleDefault。如果此方法有效,请查看以下内容以了解更多详细信息:
https://stackoverflow.com/questions/5577120
复制相似问题