2011-05-05 64 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]; 
    } 
相關問題