0

I am trying to add a button to the navigation bar in the view, but it is not showing up.

I have:

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"audio-controls"] style:UIBarButtonItemStylePlain target:self action:@selector(toggleAudioPlaybackView:)];

in a viewDidLoad.

EDIT: It is also important to note that I am also using storyboard.

EDIT: I think there is an issue with self.navigationItem... it's not nil but no changes are being made to it.

12
  • Does the image exist in your app bundle with that exact name (plus the .png extension)? Is the view controller being displayed in a UINavigationController?
    – rmaddy
    Feb 28, 2014 at 16:58
  • Always check the pieces. Is [UIImage imageNamed:@"audio-controls"] nil?
    – matt
    Feb 28, 2014 at 17:02
  • @rmaddy Image name need not have ".png" extension.
    – Srikanth
    Feb 28, 2014 at 17:15
  • @SRIKANTHKV It does if you don't specify an extension when calling imageNamed:.
    – rmaddy
    Feb 28, 2014 at 17:19
  • @rmaddy It works for me even without giving the extension. Just tested now to be sure.
    – Srikanth
    Feb 28, 2014 at 17:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.