UINavigationController 不弹出 UINavigationBar 项目

2023-06-12移动开发问题
1

本文介绍了UINavigationController 不弹出 UINavigationBar 项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

当 UINavigationController 弹出视图控制器时,我的 UINavigationBar 没有弹出它的项目.

I'm having a problem where my UINavigationBar isn't popping it's items when the UINavigationController pops a view controller.

我查看了堆栈,观察到以下内容:

I have had a look at the stacks observed the following:

  • 分配的导航控制器的预期数量(在仪器中签入)
  • 堆栈中有正确数量的控制器.(调试日志记录)
  • 导航项未弹出.(调试日志记录)

这就是我所做的.

我在调用 super 后在 viewDidLoad 方法中弹出了一些日志语句.

I popped some log statements into the viewDidLoad method after calling super.

NSLog(@"%@", [self navigationController]);
NSLog(@"%@", [[self navigationController] viewControllers]);
NSLog(@"%@", [[self navigationController] navigationBar]);
NSLog(@"%@", [[[self navigationController] navigationBar] items]);

加载初始视图后.

2009-10-09 16:42:51.706 Bob[11657:207] <UINavigationController: 0x243bb0>
2009-10-09 16:42:51.720 Bob[11657:207] (
    <MediaBrowser: 0x2354c0>
)
2009-10-09 16:42:51.742 Bob[11657:207] <UINavigationBar: 0x243e50; frame = (0 20; 320 44); autoresize = W; layer = <CALayer: 0x243ed0>>
2009-10-09 16:42:51.758 Bob[11657:207] (
    <UINavigationItem: 0x242d60>
)

一切看起来都不错.推动第二个控制器.

All looks good. Push the second controller.

2009-10-09 16:43:11.800 Bob[11657:207] -[MediaBrowser beginLoading] [Line 261] 
2009-10-09 16:43:12.320 Bob[11657:207] -[MediaBrowser loadingComplete] [Line 269] 
2009-10-09 16:43:12.587 Bob[11657:207] <UINavigationController: 0x243bb0>
2009-10-09 16:43:12.654 Bob[11657:207] (
    <MediaBrowser: 0x2354c0>,
    <MediaBrowser: 0x2c1cc0>
)
2009-10-09 16:43:12.685 Bob[11657:207] <UINavigationBar: 0x243e50; frame = (0 20; 320 44); autoresize = W; layer = <CALayer: 0x243ed0>>
2009-10-09 16:43:12.734 Bob[11657:207] (
    <UINavigationItem: 0x242d60>,
    <UINavigationItem: 0x2c63b0>
)

这里也没有什么意外的.推动第三个控制器.

Again nothing unexpected here. Push the third controller.

2009-10-09 16:43:19.934 Bob[11657:207] -[MediaBrowser beginLoading] [Line 261] 
2009-10-09 16:43:20.388 Bob[11657:207] -[MediaBrowser loadingComplete] [Line 269] 
2009-10-09 16:43:20.928 Bob[11657:207] <UINavigationController: 0x243bb0>
2009-10-09 16:43:20.962 Bob[11657:207] (
    <MediaBrowser: 0x2354c0>,
    <MediaBrowser: 0x2c1cc0>,
    <MediaBrowser: 0x4027e20>
)
2009-10-09 16:43:21.003 Bob[11657:207] <UINavigationBar: 0x243e50; frame = (0 20; 320 44); autoresize = W; layer = <CALayer: 0x243ed0>>
2009-10-09 16:43:21.039 Bob[11657:207] (
    <UINavigationItem: 0x242d60>,
    <UINavigationItem: 0x2c63b0>,
    <UINavigationItem: 0x4028880>
)

一切都好.现在让我们弹出一个控制器

All good. Now lets pop a controller

2009-10-09 16:43:26.935 Bob[11657:207] <UINavigationController: 0x243bb0>
2009-10-09 16:43:26.945 Bob[11657:207] (
    <MediaBrowser: 0x2354c0>,
    <MediaBrowser: 0x2c1cc0>
)
2009-10-09 16:43:26.964 Bob[11657:207] <UINavigationBar: 0x243e50; frame = (0 20; 320 44); autoresize = W; layer = <CALayer: 0x243ed0>>
2009-10-09 16:43:26.977 Bob[11657:207] (
    <UINavigationItem: 0x242d60>,
    <UINavigationItem: 0x2c63b0>,
    <UINavigationItem: 0x4028880>
)

嗯.出了点问题.控制器已弹出,但导航项仍然存在.咯咯笑,让我们再推一下.

Humm. Something is going amiss. The controller has popped but the navigation item is still there. For giggles lets push again.

009-10-09 16:44:05.878 Bob[11657:207] <UINavigationController: 0x243bb0>
2009-10-09 16:44:05.908 Bob[11657:207] (
    <MediaBrowser: 0x2354c0>,
    <MediaBrowser: 0x2c1cc0>,
    <MediaBrowser: 0x407eb00>
)
2009-10-09 16:44:05.951 Bob[11657:207] <UINavigationBar: 0x243e50; frame = (0 20; 320 44); autoresize = W; layer = <CALayer: 0x243ed0>>
2009-10-09 16:44:05.996 Bob[11657:207] (
    <UINavigationItem: 0x242d60>,
    <UINavigationItem: 0x2c63b0>,
    <UINavigationItem: 0x4028880>,
    <UINavigationItem: 0x407f280>
)

控制器堆栈看起来不错,导航项堆栈有很多麻烦.让我们最后一次弹出.

The controller stack looks good, the navigation item stack is in lots of trouble. Lets pop one last time.

2009-10-09 16:44:17.770 Bob[11657:207] <UINavigationController: 0x243bb0>
2009-10-09 16:44:17.776 Bob[11657:207] (
    <MediaBrowser: 0x2354c0>,
    <MediaBrowser: 0x2c1cc0>
)
2009-10-09 16:44:17.785 Bob[11657:207] <UINavigationBar: 0x243e50; frame = (0 20; 320 44); autoresize = W; layer = <CALayer: 0x243ed0>>
2009-10-09 16:44:17.793 Bob[11657:207] (
    <UINavigationItem: 0x242d60>,
    <UINavigationItem: 0x2c63b0>,
    <UINavigationItem: 0x4028880>,
    <UINavigationItem: 0x407f280>
)

所以控制器堆栈很好.另一方面,导航项存在一些问题.

So the controller stack is fine. Navigation items on the other hand have some issues.

我被难住了.我确定我在做一些奇怪/奇怪/错误的事情,但如果我能看到它,我该死.我要做的唯一操作是准备(通过我的控制器 navigationItem 属性)自定义 rightBarItem.

I'm stumped. I'm sure I'm doing something odd/weird/wrong but damn me if I can see it.The only manipulation i'm going is preparing (via my controllers navigationItem property) a custom rightBarItem.

如果你能做到这一点,谢谢.对我可能从这里去哪里的想法将不胜感激.

If you got this far, thanks. Thoughts on where I might go from here would be appreciated.

推荐答案

搞定了.

原来是做了一些愚蠢的事情.

So it turns out that I was doing something stupid.

我在 NSMutableArray 的内部类别中添加了一个 pop 方法.该方法没有正确弹出.UINavigationBar 还必须向 NSMutableArray 添加一个 pop 方法.我的越野车赢得并打破了 UIBarItem 的流行.

I had added a pop method in an internal category to NSMutableArray. That method wasn't popping correctly. UINavigationBar must also add a pop method to NSMutableArray. My buggy one was winning and breaking the pop of the UIBarItem.

这篇关于UINavigationController 不弹出 UINavigationBar 项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

硬件音量按钮更改应用程序音量
Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)...
2024-08-12 移动开发问题
10

Cocos2d - 如何检查不同层中对象之间的交集
Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)...
2024-08-12 移动开发问题
8

突出显示朗读文本(在 iPhone 的故事书类型应用程序中)
Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))...
2024-08-12 移动开发问题
9

Cocos2D + 仅禁用 Retina iPad 图形
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)...
2024-08-12 移动开发问题
10

正确的 cocos2d 场景重启?
Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)...
2024-08-12 移动开发问题
7

[ios.cocos2d+box2d]如何禁用自动旋转?
[ios.cocos2d+box2d]how to disable auto-rotation?([ios.cocos2d+box2d]如何禁用自动旋转?)...
2024-08-12 移动开发问题
7