2

I have an app which is to be run on both iPhone and iPad. I am setting a UIBarButton Item in one of my ViewControllers but for some reason it shows on the iPhone but not on the iPad (Simulator or real device).

I am using the following code to get the button image (which is a system button image) for both iPhone and iPad"

UIBarButtonItem *showButtonButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(loadButtonVC)];
self.navigationItem.leftBarButtonItem = showButtonButton;

I am at a loss. Both devices are running iOS 7 and the app is targeted at only iOS 7. But the image does not show on the iPad, the button is there as it still responds to pressing it.

2
  • Your code on a fresh universal project works like a charm on both iPhone/iPad. Are you sure that the controller on iPad is embedded in a navigation controller?
    – Alladinian
    Nov 6, 2013 at 13:26
  • Yeah it's definitely embedded in a NavigationController, it's the Root ViewController. I can set the button in the Storyboard and it works. Which will do for me. Thanks anyway.
    – SamRowley
    Nov 6, 2013 at 13:33

1 Answer 1

1

use this code

UIBarButtonItem *refreshBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self
                                   action:@selector(loadButtonVC)];
    self.navigationController.navigationBar.topItem. leftBarButtonItem = refreshBtn;
3
  • I've tried this and it doesn't work. I can't see what is going wrong at all.
    – SamRowley
    Nov 6, 2013 at 13:12
  • thats weird then,because i also had the same problem but worked with above code.have u tried the custom button??not the System refresh button..may be that could b the issue then Nov 6, 2013 at 13:15
  • I have used a custom button but the image is slightly different. Seeing as i'm using the system I can't get it as perfect and can't seem to find a link to get the asset directly.
    – SamRowley
    Nov 6, 2013 at 13:17

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.