2013-10-08 17 views
2

我有一個UISearchViewController(使用故事板佈局)的問題。UISearchbar&SearchDisplay控制器沒有在iOS7中的狀態欄下延伸

我的主視圖控制器在頂部有一個導航欄,在其下我定位了UISearchBar。 MKMapView延伸到搜索欄和導航欄下方。

當SearchViewController處於活動狀態時,導航欄向上滑動。我添加了一個自動佈局約束來將uisearchbar粘貼到導航欄的底部。但是,搜索欄似乎並未在狀態欄下方和地圖視圖上方延伸。相反,mapview出現在上面20px的空白處。

Main view controller

search view controller active

任何幫助將不勝感激!

+0

重複的問題在這裏http://stackoverflow.com/questions/19141886/uisearchbar-clipped-under-status-bar-when-added-to-uisearchdisplaycontroller/19353407#19353407 – DZenBot

+0

@ rbaker86你設法找到一個辦法?我也在努力... – PJC

+0

是的。在我的情況下:self.ibSearchBar.clipsToBounds = NO;在viewDidLoad – rbaker86

回答

0

我認爲它可以通過navigationBar.translucent = NO修復;它在iOS 7中默認設置爲YES。自己有很多麻煩。

+0

非常感謝您的建議。我試過self.navigationController.navigationBar.translucent = NO;在viewDidLoad方法中,但這沒有幫助。 – rbaker86

0

在Info.plist文件試試這個停用狀態欄

Try this in info.plist file to disable the status bar

1

設置半透明的假我的導航欄上沒有修復這個問題。然而,設置我的searchBar的半透明屬性爲我工作。

我使用這些UISearchDisplayDelegate方法來更改值,具體取決於searchBar是否處於活動狀態。

func searchDisplayControllerWillBeginSearch(controller: UISearchDisplayController) { 
    // self.searchBar is an IBOutlet from storyboard 
    self.searchBar.translucent = false 
} 

func searchDisplayControllerWillEndSearch(controller: UISearchDisplayController) { 
    self.searchBar.translucent = true 
}