Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 21st, 2012  |  syntax: None  |  size: 0.74 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Why does my custom cell only highlight when the user removes their finger?
  2. - (void)layoutSubviews
  3. {
  4.     [super layoutSubviews];
  5.  
  6.     self.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"NormalImage"]];
  7.     self.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"HighlightedImage"]];
  8.  
  9.     // other layout stuff
  10. }
  11.        
  12. - (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
  13. {
  14.     [super setHighlighted:highlighted animated:animated];
  15.     if (highlighted) {
  16.     self.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"HighlightedImage"]];
  17.  
  18.     } else {
  19.     self.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"NormalImage"]];
  20.  
  21.     }
  22. }