0

現在画像とテキストを表示しているが詳細テキストは表示していないカスタムセルを作成しました。

「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の担当者なしで画像を添付することは許可されていません):

ここに画像の説明を入力してください

4

3 に答える 3

0
    cell.textLabel.text = [currentSong objectForKey:@"Song"];
    cell.detailTextLabel.text = @"YourName"; //[currentArtist objectForKey:@"Artist"];
    cell.detailTextLabel.textColor = [UIColor redColor];
    cell.textLabel.textColor = [UIColor blackColor];//Change your color
    cell.imageView.image = [UIImage imageNamed:[currentArtist objectForKey:@"Artwork"]];

このようにしてみてください。それは私のXcodeで動作します。

于 2012-05-16T12:13:04.307 に答える
0

この行を変更してみてください。

cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

代わりに、スタイルのデフォルトで初期化します。それが役立つかどうかを確認してください。

于 2012-05-16T13:18:07.557 に答える
0

問題は、カスタムセルの高さが小さすぎることでした。とにかく、高さを上げると機能したためだと思います。

于 2012-05-18T10:32:17.057 に答える