iPhone/iPad:如何更改主页位置或取消或 UINavigationController 中的任何按钮(带或不带 InterfaceBuilder)

发布于 2024-10-13 01:31:58 字数 604 浏览 3 评论 0原文

我的问题相当简单明了。

我见过实现可以添加到 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

岁月无声 2024-10-20 01:31:58

我同意“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

海的爱人是光 2024-10-20 01:31:58

他们不会让这变得容易,因为这会打破用户的期望。我建议反对。如果您非常需要它,您可能需要制作自己的导航栏。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文