Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mikezang

macrumors 6502a
Original poster
May 22, 2010
861
9
Tokyo, Japan
I made a TabBarController, there is a SplitViewController in one tab. The Split View is no any problems, but when I switch tabs at portrait mode, I found a problem due to this undocument structure. I use code as below for split view, I am not sure how to inform it to remove button when switched tabs, pls give a hint.
Code:
- (void)splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc {
    barButtonItem.title = @"Master List";
    NSMutableArray *items = [[toolbar items] mutableCopy];
    [items insertObject:barButtonItem atIndex:0];
    [toolbar setItems:items animated:YES];
    [items release];
    self.popoverController = pc;
}


// Called when the view is shown again in the split view, invalidating the button and popover controller.
- (void)splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {
	NSMutableArray *items = [[toolbar items] mutableCopy];
    [items removeObjectAtIndex:0];
    [toolbar setItems:items animated:YES];
    [items release];
    self.popoverController = nil;
}
 

Attachments

  • SnapShot 2010-08-16 at 23.21.51.jpg
    SnapShot 2010-08-16 at 23.21.51.jpg
    35.9 KB · Views: 75
  • SnapShot 2010-08-16 at 23.21.57.jpg
    SnapShot 2010-08-16 at 23.21.57.jpg
    63.2 KB · Views: 71
  • SnapShot 2010-08-16 at 23.22.05.jpg
    SnapShot 2010-08-16 at 23.22.05.jpg
    36 KB · Views: 56
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.