开发者

How to change didSelectRow Color from blue to orange? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
开发者_开发问答

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 9 years ago.

Improve this question

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 below imageColor(orange color) (eg. third row). How can I do this?

How to change didSelectRow Color from blue to orange? [closed]


Try this code:-- put the code inside the given method

- (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];
}


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


First, you need to set backgroundView as others said. Second, when the cell is selected, it will call -(void)setSelected:animated: and -(void)setHighlighted:animated: of UITableViewCell. I suppose your cell is custom, subclassing from UITableViewCell.

I like to override the -(void)setHighlighted:animated: method, and inside the method, I will do following things.

-(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];
  }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜