UINavigationbar Prompt overlaps the screen content

两盒软妹~` 提交于 2019-12-12 20:32:59

问题


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.

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


回答1:


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;
}

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.



来源:https://stackoverflow.com/questions/19460305/uinavigationbar-prompt-overlaps-the-screen-content

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!