title: UIBarButtonItem not toggling between Play and Pause
body: <p>I have written the following code to toggle a button between identifiers play and pause. The button must be of type play when it is paused and paused when it is playing.</p>
  
  <pre><code>- (IBAction)playSound:(id)sender {
  
      if (isPaused) {
          playOrPauseButton = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemPause target:self action:@selector(pausePlaying)];
  //        playOrPauseButton.style = UIBarButtonSystemItemPause;
  //        [playOrPauseButton setStyle:UIBarButtonSystemItemPause];
          isPaused = NO;
          NSLog(@"Playing");
      }
  
      else {
  
          playOrPauseButton = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:@selector(resumePlaying)];
  //        playOrPauseButton.style = UIBarButtonSystemItemPlay;
  //        [playOrPauseButton setStyle:UIBarButtonSystemItemPlay];
          isPaused = YES;
          NSLog(@"Paused");
  
      }
  
  }
  </code></pre>
  
  <p>The commented statements are the different options that I got from web that I tried out one by one. None of the three options is toggling between the play and pause state. I have set the button identifier as play in the storyboard. Whatever I do the button is still play button. What can I do to toggle the button as play/pause type?</p>