首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >cell.detailTextLabel不工作

cell.detailTextLabel不工作
EN

Stack Overflow用户
提问于 2013-01-30 06:52:02
回答 3查看 735关注 0票数 0

我想为我的表设置一个textLabel和一个detailTextLabel。textLabel工作正常。但是,我无法让detailTextLabel显示我设置的文本。下面是我的代码

代码语言:javascript
复制
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
    }

    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.text = @"SomeString";
    cell.detailTextLabel.text = @"hello";

    return cell;
}
EN

回答 3

Stack Overflow用户

发布于 2014-01-09 05:04:57

我遇到过类似的问题,比如@user1829700。

我的初始设置是

TableView -->原型单元格--> (属性检查器)样式-设置为自定义(按设计)

将样式更改为- Subtitle,这样做是可行的

票数 1
EN

Stack Overflow用户

发布于 2013-01-30 11:32:54

尝试使用适当的UITableViewCellStyle (除了UITableViewCellStyleDefault之外的任何东西都应该可以)。单元格的样式是在初始化时指定的。

票数 0
EN

Stack Overflow用户

发布于 2013-11-16 22:21:00

在您的自定义表单元格实现中,尝试添加@synthesize detailTextLabel;

报头(.h):

代码语言:javascript
复制
@property (nonatomic, weak) IBOutlet UILabel *textLabel;
@property (nonatomic, weak) IBOutlet UILabel *detailTextLabel;

实现(.m):

代码语言:javascript
复制
@synthesize textLabel;
@synthesize detailTextLabel;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14593545

复制
相关文章

相似问题

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