iOS 5 UINavigationBar 删除子视图(图像子视图)删除导航栏

iOS 5 UINavigationBar removing subviews ( image subview) removes navigation bar(iOS 5 UINavigationBar 删除子视图(图像子视图)删除导航栏)
本文介绍了iOS 5 UINavigationBar 删除子视图(图像子视图)删除导航栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

在我在 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 删除子视图(图像子视图)删除导航栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

AWS DynamoDB Batch Get Request - iOS(AWS DynamoDB 批量获取请求 - iOS)
Querying DynamoDB on non-key attributes(在非关键属性上查询 DynamoDB)
DynamoDB auto incremented ID amp; server time (iOS SDK)(DynamoDB 自动递增 ID amp;服务器时间(iOS SDK))
Where to find a clear explanation about swift alert (UIAlertController)?(哪里可以找到关于 swift alert (UIAlertController) 的清晰解释?)
Swift alert view with OK and Cancel: which button tapped?(带有 OK 和 Cancel 的 Swift 警报视图:点击了哪个按钮?)
Facebook Requests Dialog: Frictionless Requests in native iOS app possible?(Facebook 请求对话框:本机 iOS 应用程序中的无摩擦请求可能吗?)