Search bar getting hidden by navigation bar when becomes active

孤街浪徒 提交于 2019-12-07 05:49:19

问题


I am facing a weird scenario, I have used a search bar in my application and tied it up with a table view as is seen in the below image!

But when ever I try to search anything the search bar slides up and gets hidden by navigation bar, I have used search bar a number of times and never seen me thing like this below is its screen shot !

I can't remove the navigation bar since I need it, but I just can't figure out why or how it can be happening,

One point to note is that the search bar and it's controller are working perfectly when tried to search, only thing is it's getting hidden behind the navigation bar,

Any help on this would be appreciated, as I just can't figure out its reason.


回答1:


Try this:

Set the navigation bar's translucent property to NO:

self.navigationController.navigationBar.translucent = NO;

This line will fix the view from being framed underneath the navigation bar and status bar.

If you have to show and hide the navigation bar, then use this code in viewDidLoad

 if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
    self.edgesForExtendedLayout = UIRectEdgeNone;   // iOS 7 specific


来源:https://stackoverflow.com/questions/27620339/search-bar-getting-hidden-by-navigation-bar-when-becomes-active

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