缺省实现中缺lessUITableViewCell detailTextLabel

这似乎是一个重复的问题,但我已阅读所有主题,我还没有find我的答案,所以我决定发表一个新的问题。

我正在使用UITableViewCellStyleSubtitle默认实现,但detailTextLabel不会出现,除非我每次创build一个新的单元格。

这是代码

 - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. [tblvUsersList registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return (self.registeredUser && self.registeredUser.count > 0)?self.registeredUser.count:0; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; } if (self.registeredUser.count > indexPath.row) { AppDelegate* appDelegate = [[UIApplication sharedApplication] delegate]; if (self.currentViewType == ViewTypeUsers) { UserModal* user = [self.registeredUser objectAtIndex:indexPath.row]; cell.textLabel.text = user.userName; cell.detailTextLabel.text = user.email; // NSLog(@"Detail Text is %@",cell.detailTextLabel.text); //Console Prints Null here } return cell; } 

尝试改变线路

 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 

 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];