开发者

How do you add a UIToolbar to both views of the UISplitViewController?

开发者 https://www.devze.com 2023-02-14 07:09 出处:网络
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.jpg

And then have it merged in vertical view? Here is an example from the IMDB app.

How do you add a UIToolbar to both views of the UISplitViewController?

http://img39.imageshack.us/img39/5636/imdb2.jpg http://img39.imageshack.us/img39/5636/imdb2.jpg

They 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 UIToolbars 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;
  // …
}
0

精彩评论

暂无评论...
验证码 换一张
取 消