Can't set UITableViewCell detailTextLabel.text

The detailed text of the TextLabel is not displayed, so I thought that there was a source. TextLable.text is displayed accordingly, though.

- (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... if ([[NSUserDefaults standardUserDefaults] objectForKey:@"favouriteListArray"] != nil) { NSArray *listArray = [NSArray arrayWithArray:[[NSUserDefaults standardUserDefaults] objectForKey:@"favouriteListArray"]]; NSLog(@"listArray:%@", listArray); NSDictionary *listDic = [listArray objectAtIndex:indexPath.row]; NSLog(@"listDic:%@", listDic); cell.textLabel.text = [listDic objectForKey:@"Description"]; cell.detailTextLabel.text = [listDic objectForKey:@"Address"]; } return cell; } 

NSLogs listDic

 listDic:{ Address = myAddress; Description = myDescription; } 
+4
source share
2 answers
  cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; 

You need to use initWithStyle: UITableViewCellStyleSubtitle

+10
source

Swift (3)

 let cell = UITableViewCell(style: .subtitle, reuseIdentifier: "cellIdentifier") 
0
source

All Articles