在我在 iOS 4 上运行良好的应用程序中,从 iOS 5 开始导航栏消失了.这是我认为导致问题的原因:我正在删除 RootViewController viewWillAppear 方法中的子视图:
In my application that works fine on iOS 4 navigationBar dissappeared starting iOS 5. Here is what I figured caused issue: I was removing subviews in RootViewController viewWillAppear method:
for(UIView* view in self.navigationController.navigationBar.subviews)
{
if ([view isKindOfClass:[UILabel class]])
{
[view removeFromSuperview];
}
if([view isKindOfClass:[UIImageView class]])
{
[view removeFromSuperview];
}
}
我这样做是因为我推送到导航控制器上的第二个视图控制器将图像和标签添加到导航栏,当视图弹出时我必须删除它们.在 iOS 5 中,上面的代码删除了导航栏.如何解决此问题或以正确的方式支持 iOS4 和 iOS 5?
I was doing this because Second view controller that I push onto navigation controller add's image and label to navigation bar which I have to remove when view is popped. In iOS 5 the above code removes navigationBar. How to fix this or right way of doing it to support both iOS4 and iOS 5 ?
为这些图像和 uilabel 设置标签,然后从上面的代码中删除它就可以了.
setTag for those image and uilabel then removing it from code above did the trick.
for(UIView* view in self.navigationController.navigationBar.subviews)
{
if(view.tag == 9 || view.tag == 99)
{
[view removeFromSuperview];
}
}
这篇关于iOS 5 UINavigationBar 删除子视图(图像子视图)删除导航栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!