如何从蓝色变为didSelectRow颜色橙色

问题描述:

我的问题是...如何从蓝色变为didSelectRow颜色橙色

cell have already an image(of size 320 * 103) and text- Highs And Lows from The 'Raly To Restore Sanity And....as shown in first cell, My problem is that when i select any row for navigating to the detailsViewController the cellimage(of size 320 * 103) color should be change as like shown in bellow imageColor(orange color) (eg. third row). How to do this. Please help me.

这对我来说迫在眉睫。请 感谢:

+1

接受一些答案,否则你是不会得到任何答案在未来... – visakh7 2011-05-05 11:16:25

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

- (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

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

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

首先,您需要设置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]; 
    }