背景として画像を持つカスタム UITableViewCell (XIB からインスタンス化) があります。ここで、セルが選択されたときに別の画像を背景にする必要があります(標準セルの青色の点滅に似ています)。setSelectedBackgroundView
in(void)setSelected:(BOOL)selected animated:(BOOL)animated
または inを使用して設定しようとしましdidSelectRowAtIndexPath
たが、強調表示の背景が表示されません。私は何を間違っていますか?
1324 次
3 に答える
3
カスタム Cell.xib で
次はこれを作る
そして最後にこうする
于 2013-05-01T07:02:00.793 に答える
2
以下のように試しましたか
(cellForAtIndexPath)
同じタスクを実行するための TableView DataSource メソッドから以下のメソッドを呼び出す
- (void)setCellBGColorNormalAndSelectedForTableViewCell:(UITableViewCell*)cell cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
UIImageView *normalCellBG = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, cell.frame.size.width, cell.frame.size.height)];
[normalCellBG setImage:[UIImage imageNamed:@"box_nonselected.png"]];//Set Image for Normal
[normalCellBG setBackgroundColor:[UIColor clearColor]];
[cell setBackgroundView:normalCellBG];
UIImageView *selecetedCellBG = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, cell.frame.size.width, cell.frame.size.height)];
[selecetedCellBG setImage:[UIImage imageNamed:@"box_selected.png"]];//Set Name for selected Cell
[selecetedCellBG setBackgroundColor:[UIColor clearColor]];
[cell setSelectedBackgroundView:selecetedCellBG ];
}
于 2013-05-01T07:03:03.000 に答える
1
XIB
用に作成した を使用して、選択した背景ビューを設定できますCustomCell
。あなたはそれを取る必要があるだけですUIImageView
(XIB
のimageview
高さと同じでなければなりませんCustomCell
)。そのためのアウトレット名 " selectedBackgroundView
" をCustomCell
、UIImageView
選択した背景ビューとして取ったものに接続します。selectionStyle
そのfor がCustomCell
none でないかどうかも確認します。
于 2013-05-01T06:54:03.017 に答える