我已经创建了一个自定义单元格,它目前正在显示图像和文本,但不是详细信息文本。UITableView detailTextLabel不能与自定义单元格一起工作
即使使用“cell.detailTextLabel.text”,它仍然不会显示。有人会有什么想法吗?
我试着将UITableViewCellStyleSubtitle改为UITableViewCellStyleDefault和其他。
我已经搜索了这个网站和谷歌最近几个小时尝试修复,他们都没有工作。
任何帮助,将不胜感激。
-(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"]]
}
下面是细胞的截图链接(我不能附加图像无10 REP):
感谢您的回复,我只是试了一下,它仍然没有创建一个detailTextLabel。 textLabel居中在单元格中间,看起来好像没有空间显示字幕文本 - 查看我添加的截图 – mhorgan