Search code examples
xcodeios5uitableviewcustom-celldetailtextlabel

UITableView detailTextLabel not working with custom cell


I've created a custom cell which currently is showing an image and text, but not the detail text.

Even with "cell.detailTextLabel.text", it still won't show. Would anybody have an idea what's wrong?

I've tried changing UITableViewCellStyleSubtitle to UITableViewCellStyleDefault and others.

I've searched this site and google for the last couple of hours trying fixes, none of them worked.

Any help would be appreciated.

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"myCell";
    UITableViewCell *cell = (UITableViewCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];

    }

NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:nil ascending:YES selector:@selector(localizedCompare:)];
NSArray *sortedCategories = [self.tweetSongs.allKeys sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];

NSString *categoryName = [sortedCategories objectAtIndex:indexPath.section];

NSArray *currentCategory = [self.tweetSongs objectForKey:categoryName];

NSDictionary *currentArtist = [currentCategory objectAtIndex:indexPath.row];
NSDictionary *currentSong = [currentCategory objectAtIndex:indexPath.row];

cell.textLabel.text = [currentSong objectForKey:@"Song"];
cell.detailTextLabel.text = [currentArtist objectForKey:@"Artist"];
cell.textLabel.textColor = [UIColor whiteColor];
cell.imageView.image = [UIImage imageNamed:[currentArtist objectForKey:@"Artwork"]]
}

Here's a link to the screenshot of the cells (i'm not allowed to attach an image without a rep of 10):

enter image description here


Solution

  • The problem was that the custom cell's height was too small, i think anyway because it worked when I increased the height.