UINavigationbar提示重叠屏幕内容 [英] UINavigationbar Prompt overlaps the screen content

查看:113
本文介绍了UINavigationbar提示重叠屏幕内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

遇到了一个奇怪的问题。如果我在导航控制器上设置提示,则导航栏会重叠屏幕内容。处理这个问题的正确方法是什么?

ran into a weird issue. If I set the prompt on the navigation controller, navbar overlaps the content of the screen. What is the proper way of dealing with this?

    -(id)initwithsomestuff:(stuff)
    {
...
    self.title = @"My Title";
    self.navigationItem.prompt = "@Prompt";
...
    }

当推动此视图控制器时,它首先出现,然后它调整其导航栏的大小以显示其中的提示。但这有一个令人讨厌的副作用,就是不调整下面的屏幕内容并覆盖我在屏幕上实际需要的大量内容。

When this view controller is pushed on, it first appears, then it resizes it's navigation bar to show the prompt in it. But that has a nasty side effect of not resizing the screen content below and covers a good amount of stuff I actually need on the screen.

处理这个问题的首选方法是什么?问题?如果有帮助,布局在xib中。

What's a preferred way of handling this issue? Layout is in xib if that helps.

推荐答案

你遇到的一个问题是你的init函数需要调用super。按照你的例子,它看起来像这样:

One problem you have is your init function needs to call super. Following your example, it would look like this:

- (id)initWithSomeStuff:(id)stuff
{
    self = [super init];
    if (self) {
        self.title = @"My Title";
        self.prompt = @"Prompt";
    }
    return self;
}

接下来,您是针对iOS 7开发的吗?默认情况下,使用导航栏覆盖内容的行为。如果要禁止此行为,请在视图控制器上执行以下操作:

Next, are you developing against iOS 7? It is intended behavior to cover the content with the navigation bar by default. If you want to suppress this behavior, perform the following on your view controller:

self.edgesForExtendedLayout = UIRectEdgeNone; 
self.extendedLayoutIncludesOpaqueBars = NO; 

您还可以在故事板中的视图控制器上设置这些。它们显示在属性选项卡上的扩展边缘下。

You can also set these on the View Controller in the Story board. They are shown on the Properties tab, under Extend Edges.

这篇关于UINavigationbar提示重叠屏幕内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆