私はUITableView
SplitView アプリの私の MasterView を持っています。
行を選択すると、その行の色が青色になります。黒かダークグレーに変更したいです。どうやってやるの?
ありがとう。
私はUITableView
SplitView アプリの私の MasterView を持っています。
行を選択すると、その行の色が青色になります。黒かダークグレーに変更したいです。どうやってやるの?
ありがとう。
-(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];
}
次の列挙型が選択スタイル用に定義されています -
typedef enum {
UITableViewCellSelectionStyleNone,
UITableViewCellSelectionStyleBlue,
UITableViewCellSelectionStyleGray
} UITableViewCellSelectionStyle;
したがって、目的のために使用できます-UITableViewCellSelectionStyleGray
選択したセルの色を次のように変更できます。
- (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 ピクセルの画像です。