首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >标签未在UITableView中显示

标签未在UITableView中显示
EN

Stack Overflow用户
提问于 2011-04-07 14:53:36
回答 6查看 3.1K关注 0票数 0
代码语言:javascript
复制
-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不能在表视图中显示。我的代码中有没有什么错误?

EN

回答 6

Stack Overflow用户

回答已采纳

发布于 2011-04-07 15:05:39

票数 0
EN

Stack Overflow用户

发布于 2011-04-07 14:57:46

您必须将单元格styleSubtitle设置为副标题,如下所示

代码语言:javascript
复制
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
票数 2
EN

Stack Overflow用户

发布于 2011-04-07 14:58:04

确保您使用的是UITableViewCellStyle anything,而不是UITableViewCellStyleDefault。如果此方法有效,请查看以下内容以了解更多详细信息:

cell.detailTextLabel.text not working... why

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5577120

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档