【问题标题】:UINavigationController inside UIPopoverController - in iOS 7 navigation bar behind other viewsUIPopoverController 内的 UINavigationController - 在 iOS 7 导航栏中位于其他视图后面
【发布时间】:2013-11-11 05:15:08
【问题描述】:

我在弹出框内添加了一个导航控制器。该视图包含一个我想部分覆盖的图像。在iOS6 中是在导航栏的后面,在ios7 中正好相反。附上截图。 有谁知道为什么?

【问题讨论】:

    标签: ios ipad uinavigationcontroller uipopovercontroller


    【解决方案1】:

    在 iOS 7 中,默认情况下布局会扩展容器的边缘。这是edgesForExtendedLayout 视图控制器属性的控制器。如果您希望布局以与导航栏对齐的顶部开始,您需要通过设置self.edgesForExtendedLayout 来禁用它。

    例如:

    - (id)init
    {
        if ((self = [super init])) {
    
            // layout with top of view starting at bottom of navigation bar
            self.edgesForExtendedLayout = UIRectEdgeNone;
    
            // continue with init
    
        }
     }
    

    【讨论】:

      【解决方案2】:

      如果不需要导航栏半透明,可以试试navigationBar.isTranslucent = NO。

      【讨论】:

        【解决方案3】:

        使用自动布局约束:http://www.raywenderlich.com/50317/beginning-auto-layout-tutorial-in-ios-7-part-1

        或者试试这个(没有优雅的解决方案):

        NSString *ver = [[UIDevice currentDevice] systemVersion];
        float ver_float = [ver floatValue];
        
        if (ver_float >= 7.0f)
        {
           CGRect frame = self.myView.frame;
           frame.origin.y = self.navigationBar.frame.size.height;
           [self.myView setFrame:frame]
        }
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2020-03-02
          • 2016-04-27
          • 1970-01-01
          • 1970-01-01
          • 2017-04-11
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多