テーブル ビューのセルにサブタイトルを表示しようとしていますが、何らかの理由で表示されません。セルのスタイルを UITableViewCellStyleSubtitle に設定しているので、それは問題ではありません。関連するコードは次のとおりです。
- (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];
}
NMADRestaurant *restaurant = [self.restaurants objectAtIndex:indexPath.row];
cell.textLabel.text = [restaurant name];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
CLLocation *restaurantLocation = [restaurant location];
CLLocationDistance distance = [currentLocation distanceFromLocation:restaurantLocation];
NSString *distanceString = [NSString stringWithFormat:@"%.1f km",(distance/1000)];
cell.detailTextLabel.text = distanceString;
return cell;
}
NSLog distanceString の場合、正しく表示されます。しかし、I NSLog(@"Label %@",cell.detailTextLabel.text) の場合、ログに表示されるのは "Label (null)" だけです。