-1

私はUITableViewSplitView アプリの私の MasterView を持っています。

行を選択すると、その行の色が青色になります。黒かダークグレーに変更したいです。どうやってやるの?

ありがとう。

4

3 に答える 3

2
-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

static NSString *CellIdentifier = @"CellIdentifier";
UITableViewCell *tableCell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (tableCell == nil) {
    tableCell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease] ;   

[tableCell setSelectionStyle:UITableViewCellSelectionStyleGray]; 
   }
 }

または、これを試すこともできますcellForRowAtIndexPath

if (indexPath.row == selectedIndex) 
{ 
    Cell.LblDynamicCell.textColor=[UIColor whiteColor];
    Cell.LblBackView.backgroundColor=[UIColor Black];
}
//LblDynamicCell,LblBackView objects  declare in cellViewController class

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 {
  selectedIndex = indexPath.row;
  [self.ResultTbl reloadData];

 }
于 2012-06-25T06:26:35.690 に答える
2

次の列挙型が選択スタイル用に定義されています -

typedef enum {
    UITableViewCellSelectionStyleNone,
    UITableViewCellSelectionStyleBlue,
    UITableViewCellSelectionStyleGray
} UITableViewCellSelectionStyle;

したがって、目的のために使用できます-UITableViewCellSelectionStyleGray

于 2012-06-25T06:27:01.907 に答える
0

選択したセルの色を次のように変更できます。

- (void)setSelected:(BOOL)selected animated:(BOOL)animated

    {
        [super setSelected:selected animated:animated];

        UIImageView *theImageView = [[UIImageView alloc] initWithImage:[UIImage imageName:@"table_selected_cell.png"]];
        self.selectedBackgroundView = theImageView;
        [theImageView release];
    }

選択した色を変更します。ここで、table_selected_cell.png は色の 2 ピクセルの画像です。

于 2012-06-25T06:27:15.633 に答える