顶部的UIPopoverController工具栏 [英] UIPopoverController toolbar at top

查看:94
本文介绍了顶部的UIPopoverController工具栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将UIToolbar放在UIPopoverController的顶部,就像Apple在页面和主题演讲中使用media,tables,chartsshapes工具栏一样。





我设法使用与这篇文章但是我无法将它移到顶部。



我可以通过放置一个正常的方式来实现其中一个子视图控制器中的UIToolbar但工具栏似乎与边框不在同一行,并且看起来不像苹果应用程序那样好。



<有没有人对如何做到这一点有任何建议,或者甚至可能?任何帮助将不胜感激。



谢谢!

解决方案

使用一个UINavigationController只包含你的一个ViewController作为popoverController的内容,如下所示:

  MyViewController * myVC = [[myViewController alloc] init ]。 

UINavigationController * navCon = [[UINavigationController alloc] initWithRootViewController:myVC];

myPopoverController = [[UIPopoverController alloc] initWithContentViewController:navCon];

[myVC发布];
[navCon release];

[myPopoverController presentPopoverFromRect:rect
inView:view
allowedArrowDirections:UIPopoverArrowDirectionRight
animated:YES];

然后,在你的viewController的init中,设置navigationController的项目:

  self.navigationItem.title = @myTitle; 
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(editButtonTapped :)] autorelease];

你可以疯狂地把你想要的东西放在那里:

  self.navigationItem.titleView = [[MySpecialTitleView alloc] initWithFrame ...]; 

如果其堆栈中只有一个ViewController,导航控制器将无法导航。



iOS 7警告:弹出窗口中的NavigationBars似乎忽略了iOS 7中的色调。我认为这是一个错误并鼓励您在遇到此问题时向Apple提交错误报告。


I am trying to place a UIToolbar at the top of a UIPopoverController in much the same way as Apple have done in pages and keynote with the "media", "tables", "charts" "shapes" toolbar.

I've managed to place one at the bottom using the same method described as in this post but I'm unable to move it to the top.

I can do it by just placing a normal UIToolbar within one of the child view controllers however the toolbar does not seem to follow the same line as the border and doesn't look as nice as it does in the apple apps.

Does anyone have any suggestions on how to do this, or if it's even possible? Any help would be much appreciated.

Thanks!

解决方案

Use a UINavigationController that holds just your one ViewController as the popoverController's content, like so:

MyViewController *myVC = [[myViewController alloc] init];

UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:myVC];

myPopoverController = [[UIPopoverController alloc] initWithContentViewController:navCon];

[myVC release];
[navCon release];

[myPopoverController presentPopoverFromRect:rect
                                     inView:view
                   permittedArrowDirections:UIPopoverArrowDirectionRight
                                   animated:YES];

Then, in your viewController's init, set the navigationController's items:

self.navigationItem.title = @"myTitle";
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(editButtonTapped:)] autorelease];

You can go crazy and put whatever you want in there:

self.navigationItem.titleView = [[MySpecialTitleView alloc] initWithFrame...];

Your navigation controller won't be navigating if there is only one ViewController on its stack.

iOS 7 caveat: NavigationBars inside popovers seem to ignore tint in iOS 7. I think that's a bug and encourage you to file a bug report with apple if you encounter this issue.

这篇关于顶部的UIPopoverController工具栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆