How do you add a UIToolbar to both views of the UISplitViewController?
And then have it merged in vertical view? Here is an example from the IMDB app.
http://img39.imageshack.us/img39/5636/imdb2.jpg http://img39.imageshack.us/img39/5636/imdb2.jpgThey did it perfectly and I would like to know how I can replicate it. Right now, I can't seem to add it to 开发者_如何学Cthe left side of the split controller. Thanks in advance.
Short answer, you don't.
What you have is two UIToolbar
s and some code that moves the content of one onto the other when the UISplitViewController
calls its delegate's
– splitViewController:willHideViewController:withBarButtonItem:forPopoverController:
method and that moves the items back again in the delegate's
– splitViewController:willShowViewController:invalidatingBarButtonItem:
method.
For example this might work:
– splitViewController:willHideViewController:withBarButtonItem:forPopoverController:
{
// …
NSArray *leftItems = leftBar.items;
rightBar.items = [leftItems arrayByAddingObjectsFromArray:rightBar.items];
leftBar.hidden=YES;
// …
}
– splitViewController:willShowViewController:invalidatingBarButtonItem:
{
// …
NSArray *rightItems = rightBar.items;
NSUInteger lc = [leftBar.items count];
rightBar.items = [rightItems subArrayWithRange:NSMakeRange(lc,[rightItems count] - lc)];
leftBar.hidden=NO;
// …
}
精彩评论