iOS 7, scope bar becomes black in search mode

爷,独闯天下 提交于 2020-01-02 08:45:06

问题


I use UISearchDisplayController embedded to UiTableViewController to make a search bar in my table view. But if I set the search bar's background image, the scope bar do not show in search mode, but showing a black bar instead. It's very weird because it does not happen in iOS 6.

Note that the image I used to set the search bar's background image is 640x90 px, somehow the scope bar will show if use other image.

Even if I set the scope bar background image, it sill not show depend on the search bar's image setting.

I think it's a bug in iOS 7, and to prevent from other factors, I even use the master-detail template in Xcode 5, and embed the UISearchDisplayController in master view controller, change the search bar background image and scope bar shows black in search mode.

I think it has something to do with iOS 7 auto resize of view controller. Bothers me so much.

Someone please try and help. Thanks a lot a lot.

------------------------------edited-------------------------- Sometimes the scope bar will show if I change search bar background image, but in real device (iPhone5), the scope bar never show.


回答1:


I have just found a solution here: IOS7 Status bar change to black after search is active

Just put these two lines on your table view controller (viewDidLoad):

self.navigationController.view.backgroundColor = [UIColor whiteColor]; 

self.navigationController.navigationBar.translucent = NO;

Where "whiteColor" is the color that you need for the status Bar.




回答2:


I have resolved this problem by using UISearchBar appearance:

[[UISearchBar appearance] setBackgroundImage:bgImage forBarPosition:UIBarPositionTopAttached barMetrics:UIBarMetricsDefault];


来源:https://stackoverflow.com/questions/19226503/ios-7-scope-bar-becomes-black-in-search-mode

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