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 8261407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:23:46+00:00 2026-06-08T03:23:46+00:00

I have a UISplitViewController. I have multiple detail views. The detail views have toolbars.

  • 0

I have a UISplitViewController. I have multiple detail views. The detail views have toolbars. I want to move the UIBarButtonItem provided from the UISplitViewControllerDelegate between toolbars.

So I save a references to the UIBarButtonItem, and when I swap views, I remove it from the current detail view and move it to the new detail view.

The UIBarButtonItem works exactly once. If I start with view controller A in the UISplitViewController detail pane, the item is displayed in the toolbar. When I switch to view controller B, I can see the item being removed and added and it takes up space, but it never displays in the new toolbar.

I can solve this by copying the UIBarButtonItem every time I want to add it to a new toolbar. I would really just like to use the saved value.

What’s going on?

Code

My app delegate is also my UISplitViewControllerDelegate. All my detail views also conform to UISplitViewControllerDelegate.

// Save
- (void)splitViewController:(UISplitViewController *)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)pc
{
    /* Omitted code that calls the same method on the current detail view. */
    // Save the item
    self.savedBarButtonItem = barButtonItem;
}

I have an IBAction in my app delegate:

-(IBAction)changeDetailView:(id)sender
{
    /* omitted code to the the new view controller and the current view controller */
    [currentView removeBarButtonItem];

    //This adds the item but the item does not even show up.
    [newView addBarButtonItem:self.savedBarButtonItem];

    // New item with the same target and action works.
    UIBarButtonItem * newItem = 
        [[UIBarButtonItem alloc] initWithTitle:@"Test" style:UIBarButtonItemStyleBordered target:self.savedBarButtonItem.target action:self.savedBarButtonItem.action];
    [newView addBarButtonItem:newItem];

}

And the way I add and remove the UIBarButtonItems in the detail view controllers:

-(void)addBarButtonItem:(UIBarButtonItem *)barButtonItem
{
    NSArray * items = self.toolbar.items;
    NSMutableArray * newArr = [NSMutableArray arrayWithCapacity:[items count]+1];
    [newArr addObject:barButtonItem];
    for(NSObject * o in items)
        [newArr addObject:o];
    [self.toolbar setItems:newArr animated:YES];
}

-(void)removeBarButtonItem
{
    NSArray * items = self.toolbar.items;
    NSMutableArray * newArr = [NSMutableArray arrayWithCapacity:[items count]-1];
    for(NSInteger i=1; i<[items count]; i++)
        [newArr addObject:[items objectAtIndex:i]];
    [self.toolbar setItems:newArr animated:YES];
}
  • 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-08T03:23:51+00:00Added an answer on June 8, 2026 at 3:23 am

    I suspect the issue is due to the use of animation in the remove method. The toolbar most likely keeps references to the old times array around while its animating them out of the view. So what I suggest is that you try changing animated: to NO in the remove, and see if that fixes it. Perhaps try it in both. If it then works then this theory is right.

    You never mentioned if this item uses a customView or not, which might be more problematic.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an UISplitViewController base project. I want to have a different detail View
I have UISplitViewController that I want to be updated from a UIViewController that is
I have a UISplitViewController in which i'm attempting to pass an int value from
I have 4 UIBarButtonItems inside a UISplitViewController's right hand side (the detail controller). I'm
I am working on UISplitViewController, I have a pageController in my detail view of
So I have an instance of MyViewController in the detail view of a UISplitViewController.
How can I call function from UISplitViewController subclass to other ViewController. I have an
I have a UISplitViewController. When the app launches initially, the detail view is showing
I have a UISplitViewController in an iPad app. When something is selected from the
I have a custom customUIViewController in a UISplitViewController and want to access the instance

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.