iPhone/iPad:如何更改主页位置或取消或 UINavigationController 中的任何按钮(带或不带 InterfaceBuilder)
我的问题相当简单明了。
我见过实现可以添加到 UINavigationController 的按钮(例如取消按钮)的代码。代码如下所示:
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc]
initWithImage: [UIImage imageNamed:@"home.png"]
style: UIBarButtonItemStylePlain target: self
action: @selector(cancel:)];
self.navigationItem.rightBarButtonItem = cancelButton;
[cancelButton release];
我想做的是将这些按钮放置在 navigationItem 中的自定义位置...而不是默认的 rightBarButtonItem 或 leftBarButtonItem 位置,但可以使用 x 和 y 坐标进行控制...是这甚至可能吗?这似乎是一个简单的请求,但谷歌搜索和文档审查让我有点疯狂:)
我将不胜感激任何有关此问题的帮助。
再次感谢,
爱德华
My question is fairly straightforward and simple.
I have seen code that implements a button (such as a cancel button) that can be added to a UINavigationController. Code looks like this:
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc]
initWithImage: [UIImage imageNamed:@"home.png"]
style: UIBarButtonItemStylePlain target: self
action: @selector(cancel:)];
self.navigationItem.rightBarButtonItem = cancelButton;
[cancelButton release];
What I'd like to do is to place these buttons in a custom location in the navigationItem...not in the default rightBarButtonItem or leftBarButtonItem location, but controllable perhaps using x and y co-ordinates...is this even possible? It seems like a simple request, but google searching and documentation reviewing is driving me a little nuts :)
I would appreciate any assistance with this issue.
thanks again,
Edward
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我同意“Hack Saw”,因为它违反了 Apple 的“人机界面指南”,因此不推荐...但是...如果您愿意,您可以在导航栏的标题视图中绘制其他视图 [self .navigationContoller.navigationBar.topItem setTitleView]。希望有帮助!
以下是参考链接: UINavigationItem
I agree with 'Hack Saw' in the case of it being against the Apple 'Human Interface Guide' and thus not recommended...However... If you want to, you can draw additional views into the navigation bar's title view [self.navigationContoller.navigationBar.topItem setTitleView]. Hope that helps!
Here is link to reference: UINavigationItem
他们不会让这变得容易,因为这会打破用户的期望。我建议反对。如果您非常需要它,您可能需要制作自己的导航栏。
They don't make that easy because it would break user expectation. I recommend against it. If you have a serious need for it, you'll probably need to make your own navbar.