2013-08-29 143 views
14

你們有沒有偶然發現這個問題?導航控制器呈現在視圖上我導航到

基本上在iOS 7中導航控制器在我導航到的子視圖上呈現。

在iOS 6視圖中,導航欄位於導航欄和頁腳之間。在iOS 7中,它看起來像是在導航欄和頁腳下全屏顯示子視圖。因爲結果用戶沒有看到它。

這是我如何定位到子視圖

BRSMyListSubViewController *tagsInfoVC = [[BRSMyListSubViewController alloc] initWithCheckinsList:self.checkinsList 
                       selectedTag:[self tagByIndexPath:indexPath]]; 

[self.navigationController pushViewController:tagsInfoVC animated:YES]; 

這是我如何初始化它viewDidLoad

self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Settings" style:UIBarButtonItemStyleBordered target:self action:@selector(settings:)]; 

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Logout" style:UIBarButtonItemStyleBordered target:self action:@selector(logout:)]; 

對於什麼是值得我還要提到的是子視圖是使用XIB定義自動佈局。這裏是我的XIB來源:http://pastebin.com/6RR0zYu4

最後在這裏是如何看起來在iOS 6中

enter image description here

而在iOS的7

enter image description here

有什麼想法?

回答

37

嗯,我想通了。

在您的子視圖(BRSMyListSubViewController在我的情況),在viewDidLoad,你需要設置這兩個

self.edgesForExtendedLayout = UIRectEdgeNone; 
self.automaticallyAdjustsScrollViewInsets = NO; 

OR

self.edgesForExtendedLayout = UIRectEdgeNone; 
self.extendedLayoutIncludesOpaqueBars = YES; 

一個非常有趣的是在根視圖控制器,這些價值分別設置爲默認UIRectEdgeAllNOYES,但其tableView不在導航欄和頁腳下。

我不知道爲什麼它是如此不合邏輯。

奇怪的是,edgesForExtendedLayout必須與其他兩個屬性中的一個混合在一起,即使它明確地對行爲負責。

PS。對於那些誰想要在iOS 6 Surruound運行它與if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7)

+0

謝謝你提供的答案,它真的幫了我。 – titicaca

+0

非常感謝您的回答保存我的一天! –

+0

它只適用於iOS7,如果你在iOS6運行設備運行應用程序,它會給出異常,因爲iOS7 SDK屬性 –

4

代碼如果你不介意具有不透明的導航欄,那麼最簡單的解決辦法是爲此在創建您的導航控制器的視圖控制器:

self.navigationController.navigationBar.translucent = NO; 

框架,然後將採取相同的行爲iOS6的,神奇的定位!

相關問題