禁用导航项后栏按钮

发布于 2024-08-21 22:49:00 字数 99 浏览 2 评论 0原文

如何禁用导航控制器中的后退按钮?

当我像这样隐藏按钮时, self.navigationItem.hidesBackButton = TRUE; 按钮区域仍然可以点击。

How do I disable the backbutton in a navigationcontroller?

When I hide the button like so,
self.navigationItem.hidesBackButton = TRUE;
the buttonarea is still tappable.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

温柔一刀 2024-08-28 22:49:00

如果您不需要后退按钮,并且由于导航栏存在的一部分就是有一个后退按钮,您可以简单地隐藏导航栏。如果您愿意,我可以将代码发布到其中,因为我在几个项目中这样做了。否则,如果您从错误的地方调用它,那么您的“错误”可能不是错误。
经过挖掘,我设法想出了这个。
要隐藏后退按钮,请使用:

self.navigationItem.hidesBackButton = YES;

要隐藏整个导航栏,请使用:

self.navigationController.navigationBarHidden = YES;

但这会在没有动画的情况下发生,要为其设置动画,请使用以下内容:

[self.navigationController setNavigationBarHidden:YES animated:YES];

这将与导航视图一起制作滑动动画。不过,您需要提供一些其他方式让此人返回。

If you don't need a back button and since part of navigationBar's existence is to have a back button you can simply hide the navBar. I can post the code to that if you want as Im doing that in couple of projects. Otherwise have your "bug" might not be a bug if you are calling it from the wrong place.
After digging i managed to come up with this.
To hide the back button use:

self.navigationItem.hidesBackButton = YES;

To hide the whole navigationBar use:

self.navigationController.navigationBarHidden = YES;

But this will happen without animation, to animate it use this instead:

[self.navigationController setNavigationBarHidden:YES animated:YES];

This will make a sliding animation together with the navigation view. You will need to provide some other means for the person to get back tho.

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