本文介绍了UINavigationBar .items访问器不返回当前的UINavigationItem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 UINavigationBar:didPopItem:函数中,导航栏的 _itemStack 中有n个项目,在调试器中显示,但是 .items 访问器函数返回一个数组,其中包含n-1个项目,但缺少当前的导航项目,这就是我要检查的内容. backItem 返回n-2项,而不是n-1,依此类推. didPopItem 项是'n + 1'项,因此也无济于事./p>

如何访问当前的UINavigationItem?

我正在使用iPhone 3.0 SDK.

解决方案

似乎在返回RunLoop之后将对"items"属性进行调整.因此,尝试这样.

 -(void)XXX:(UINavigationBar *)nBar {UINavigationItem * cItem = [nBar.items objectAtIndex:(nBar.items.count-1)];}-(void)navigationBar:(UINavigationBar *)nBar didPopItem:(UINavigationItem *)item {[self performSelector:@selector(XXX)withObject:nBar afterDelay:0];} 

In my UINavigationBar: didPopItem: function the navigation bar's _itemStack has n items in it, shown in the debugger, but the .items accessor function returns an array with n-1 items in it, missing the current navigation item, which is what I want to check. backItem returns the n-2 item instead of the n-1, etc. The didPopItem item is the 'n+1' item so that doesn't help either.

How do I access the current UINavigationItem?

I'm using the iPhone 3.0 SDK.

解决方案

It seems that the "items" property will be adjusted after returning RunLoop.So try like this.

-(void)XXX:(UINavigationBar*)nBar {
    UINavigationItem *cItem = [nBar.items objectAtIndex:(nBar.items.count - 1)];
}

-(void)navigationBar:(UINavigationBar *)nBar didPopItem:(UINavigationItem *)item {
    [ self performSelector:@selector(XXX) withObject:nBar afterDelay:0 ];
}

这篇关于UINavigationBar .items访问器不返回当前的UINavigationItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 01:52