UINavigationController没有弹出UINavigationBar项 [英] UINavigationController not popping UINavigationBar items
问题描述
我遇到一个问题,当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。有些事情不对劲。控制器已弹出但导航项仍然存在。对于咯咯笑,我们再次推。
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.
推荐答案
Nailed it。
Nailed it.
所以事实证明我做了一些愚蠢的事。
So it turns out that I was doing something stupid.
我在内部类别中添加了一个pop方法给NSMutableArray 。该方法没有正确弹出。 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项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!