我想为我的表设置一个textLabel和一个detailTextLabel。textLabel工作正常。但是,我无法让detailTextLabel显示我设置的文本。下面是我的代码
- (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;
}发布于 2014-01-09 05:04:57
我遇到过类似的问题,比如@user1829700。
我的初始设置是
TableView -->原型单元格--> (属性检查器)样式-设置为自定义(按设计)
将样式更改为- Subtitle,这样做是可行的
发布于 2013-01-30 11:32:54
尝试使用适当的UITableViewCellStyle (除了UITableViewCellStyleDefault之外的任何东西都应该可以)。单元格的样式是在初始化时指定的。
发布于 2013-11-16 22:21:00
在您的自定义表单元格实现中,尝试添加@synthesize detailTextLabel;
报头(.h):
@property (nonatomic, weak) IBOutlet UILabel *textLabel;
@property (nonatomic, weak) IBOutlet UILabel *detailTextLabel;实现(.m):
@synthesize textLabel;
@synthesize detailTextLabel;https://stackoverflow.com/questions/14593545
复制相似问题