2011-05-05 75 views

回答

1

试试这个代码: - 把代码给定的方法

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

UIView *myBackView = [[UIView alloc] initWithFrame:cell.frame]; 
myBackView.backgroundColor = [UIColor colorWithRed:253.0/256.0 green:199.0/256.0 blue:235.0/256.0 alpha:1.0];// change the color to your orange color i used different color herer 
cell.selectedBackgroundView = myBackView; 
[myBackView release]; 
} 
+0

所接受的答案 – 2011-05-05 10:54:02

+0

喜@Aman谢谢回答我 – pinku 2011-06-30 06:07:18

1
UIView *cellBgView = [[UIView alloc] initWithFrame:cell.frame]; 
cellBgView.backgroundColor = [UIColor orangeColor]; 
cell.selectedBackgroundView = cellBgView; 
[cellBgView release]; 
+0

谢谢回答我: – pinku 2011-06-30 06:06:51

0

首先,您需要设置backgroundView的人说里面。第二,当选中单元格时,将调用-(void)setSelected:animated:-(void)setHighlighted:animated:UITableViewCell。我想你的单元格是自定义的,从UITableViewCell继承。

我喜欢重写-(void)setHighlighted:animated:方法,并且在方法内部,我会做以下事情。

-(void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated 
    { 
     [myLabel setHighlighted:highlighted]; 
     [myIconImage setHighlighted:highlighted]; 
     ///.... propagate the highlighted event to subviews. 

    // Call super method. 
    [super setHighlighted:highlighted animated:animated]; 
    } 
相关问题