0

テーブルビューでは、セルに背景画像 (完全に黒い画像) を使用し、セルにアクセサリ インジケーターも使用したいと考えています。セルのプロパティ ウィンドウで、AccessoryDisclosureIndicator を設定します

私の.mファイルに、テーブルビュー用にこれらのコードを入れました:

- (UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath{

    return UITableViewCellAccessoryDisclosureIndicator;

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";


    UITableViewCell *cell = (UITableViewCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
        cell.backgroundColor = [UIColor clearColor];

    }

    cell.textLabel.backgroundColor=[UIColor clearColor];
    cell.textLabel.text=[arrMagaza objectAtIndex:indexPath.row]; 
    cell.textLabel.textColor=[UIColor whiteColor];


    NSString *distance=[arrDistance objectAtIndex:indexPath.row];
    cell.detailTextLabel.backgroundColor=[UIColor clearColor];
    cell.detailTextLabel.textColor=[UIColor whiteColor];
    cell.detailTextLabel.text=[distance stringByAppendingFormat:@" km"];

    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;

    return cell;
}


- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
   cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tablecell.png"]];
   tableView.backgroundColor=[UIColor blackColor];
   tableView.separatorColor= [UIColor clearColor];
   cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
}

アプリを実行すると、ビューにアクセサリ インジケータが表示されません。私は何を間違っていますか?セルに使用する背景画像に関する問題ですか?

4

1 に答える 1

0
- (UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath

このメソッドは現在非推奨であるため、このメソッドを実装する必要はありません。他のすべてを削除してみてください。

于 2012-06-02T19:00:17.370 に答える