title: Why is the selected state of my UIButton not triggered before I release my finger?
body: <p>I'm trying to create a button that switches from its <code>normal</code> state to a <code>selected</code> state upon simply touching it, and the other way around. However, I didn't manage to make it work. Here is my code:</p>
  
  <pre><code>#import "ViewController.h"
  
  @interface ViewController ()
  
  @end
  
  @implementation ViewController
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
  
      UIButton *button = [UIButton new];
      [button setImage:[UIImage imageNamed:@"touch_normal.png"] forState:UIControlStateNormal];
      [button setImage:[UIImage imageNamed:@"touch_selected.png"] forState:UIControlStateSelected];
  
      button.frame = CGRectMake(138.5, 208.5, 63, 63);
      [button addTarget:self action:@selector(touch:) forControlEvents:UIControlEventTouchDown];
      button.adjustsImageWhenHighlighted = NO;
  
      [self.view addSubview:button];
  }
  
  - (void)touch:(id)sender
  {
      NSLog(@"Touch");
  
      UIButton *button = sender;
  
      if (button.selected)
          button.selected = NO;
      else
          button.selected = YES;
  }
  
  @end
  </code></pre>
  
  <p>When I tap and hold, the <code>touch</code> method is triggered, as expected. However, the image of the button only changes to <code>touch_selected.png</code> after I release my finger. Any idea what could be the issue?</p>
  
  <p><strong>Edit</strong>: I know what <code>UIControlStateHighlighted</code> is and it's not what I'm looking for, because I want my button to change to the <code>selected</code> state after I touched it (but while I'm still holding my finger on it), and it should stay in the <code>selected</code> state after I removed my finger from the screen.</p>