导航控制器在我导航到的视图上呈现

exp*_*ert 14 cocoa-touch uinavigationcontroller ios ios6 ios7

你们有没有在这个问题上跌跌撞撞?

基本上在iOS 7中,导航控制器在我导航到的子视图上呈现.

在iOS 6视图中,我导航到导航栏和页脚之间.在iOS 7中,它看起来像子视图在导航栏和页脚下全屏显示.结果用户看不到它.

以下是我导航到子视图的方法

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

[self.navigationController pushViewController:tagsInfoVC animated:YES];
Run Code Online (Sandbox Code Playgroud)

这是我如何初始化它 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:)];
Run Code Online (Sandbox Code Playgroud)

对于它的价值,我还应该提到子视图是使用Autolayout在XIB中定义的.这是我的XIB的来源:http://pastebin.com/6RR0zYu4

最后,这是它在iOS 6中的外观

在此输入图像描述

在iOS 7中

在此输入图像描述

有什么想法吗 ?

exp*_*ert 37

好吧,我明白了.

在您的子视图(BRSMyListSubViewController在我的情况下)中viewDidLoad,您需要设置这两个中的一个

self.edgesForExtendedLayout = UIRectEdgeNone;
self.automaticallyAdjustsScrollViewInsets = NO;
Run Code Online (Sandbox Code Playgroud)

要么

self.edgesForExtendedLayout = UIRectEdgeNone;
self.extendedLayoutIncludesOpaqueBars = YES;
Run Code Online (Sandbox Code Playgroud)

有趣的是在根视图控制器这些值被设置为默认UIRectEdgeAll,NOYES分别但其tableView不是下导航栏和页脚.

我不知道为什么它如此不合逻辑.

同样奇怪的是edgesForExtendedLayout,必须与其他两个属性中的一个混合,即使它明确地对行为负责.

PS.对于那些想在iOS 6上运行它的用户来说if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7)

  • @ruslan最好先进行方法检查,然后再进行系统版本检查.`if([self respondsToSelector:@selector(setEdgesForExtendedLayout :)])`只是因为系统版本和基础版本不一致. (2认同)