Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8347599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:24:27+00:00 2026-06-09T07:24:27+00:00

I am optimizing an app for iPad at the moment and would like to

  • 0

I am optimizing an app for iPad at the moment and would like to use a UIBarButtonItem with an image to present a popover. The code I currently have works great if I am using a button with a title but I would prefer to use an image of my own or one of those provided with a UIBarButtonSystemItem. If I do not set the button’s title at all, it simply will not show up. If I set a title AND an image, I get the title on real hardware but the image shows up on the simulator. Using a UIBarButtonSystemItem, I get the button I want but it appears in landscape mode as well (which it shouldn’t do because I am using a split view for landscape).

Using any combination of setImage, setTitle, or initializing the button as a system preset has not worked. I have also tried setting the button with a system preset to nil when a rotation to landscape was detected but it remained on the screen. I am unsure of how to proceed from here but I would really like to avoid using a string for this button, plus I am very curious to know why this is happening.

Here is the code:

#pragma mark Split view handling
-(void)splitViewController:(UISplitViewController *)svc 
    willHideViewController:(UIViewController *)aViewController 
         withBarButtonItem:(UIBarButtonItem *)barButtonItem 
      forPopoverController:(UIPopoverController *)pc
{
    //If this bar button item doesn't have a title, it won't appear at all.
    [barButtonItem setTitle:@"-"];
    //barButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize target:[barButtonItem target] action:[barButtonItem action]];
    [barButtonItem setImage:[UIImage imageNamed:@"listing.png"]];

    //Take this bar button item and put it on the left side of our nav item
    [[self navigationItem] setLeftBarButtonItem:barButtonItem];
    self.popoverController = pc;
}

-(void)splitViewController:(UISplitViewController *)svc 
    willShowViewController:(UIViewController *)aViewController 
 invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
    //Remove the bar button item from our navigation item.
    //We'll double check that it's the correct button, even though we know it is.
    if(barButtonItem == [[self navigationItem] leftBarButtonItem]){
        [[self navigationItem] setLeftBarButtonItem:nil];
    }
    self.popoverController = nil;
}

UPDATE:

I added this to my viewDidLoad:

customButtonItem = [[UIBarButtonItem alloc] initWithCustomView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"listing.PNG"]]];
customButtonItem.style = UIBarButtonItemStyleBordered;

And updated willHideViewController to this:

-(void)splitViewController:(UISplitViewController *)svc 
    willHideViewController:(UIViewController *)aViewController 
         withBarButtonItem:(UIBarButtonItem *)barButtonItem 
      forPopoverController:(UIPopoverController *)pc
{
    //If this bar button item doesn't have a title, it won't appear at all
    customButtonItem.target = barButtonItem.target;
    customButtonItem.action = barButtonItem.action;
    barButtonItem = customButtonItem;
    [barButtonItem setTitle:@""];

    //barButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize target:[barButtonItem target] action:[barButtonItem action]];
    //[barButtonItem setImage:[UIImage imageNamed:@"listing.png"]];

    //Take this bar button item and put it on the left side of our nav item
    [[self navigationItem] setLeftBarButtonItem:barButtonItem];
    self.popoverController = pc;
}

This resulted in the image showing up when/where I want it to but the button has no border to it (despite me setting it to) and does not present a popover.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T07:24:28+00:00Added an answer on June 9, 2026 at 7:24 am

    EDIT: I missed that this was splitView delegate and you were receiving the UIBarButtonItem from iOS. So what I would suggest you do is try the following.

    Create your own buttonItem, and copy the target and selector from the one provided by the system. Create the new button item like this:

    UIBarButtonItem *newBut = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStyleBordered target: barButtonItem.target action: barButtonItem.action];
    [[self navigationItem] setLeftBarButtonItem:newBut];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently optimizing my iOS app for the new iPad . Unfortunately by adding
I making an app and im currently optimizing it to Samsung Galaxy Tab. I
I use jQuery. I have been reading a lot about selector performance and optimizing
I have a chat like desktop java swing app, where i keep getting String
At the moment I have two versions of my App: normal and plus When
First time loading remote images into an iPhone app, and would like some help
I am optimizing the startup of a WinForms app. One issue I identified is
I need help optimizing the code to run faster, unless it is optimized the
I have been optimizing my website but the one problem that stands in my
I have been optimizing our continuous integration builds, and the remaining bottleneck seems to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.