在 iOS 7 中,如果某个 UIViewController 的 self.view 第一个子视图是 UIScollView, 同时当这个 UIViewController 被 push 或 initWithRootController 成为 UINavigationController控制的Controller时,这个 UIViewController的 view 的子视图 UIScollView 的所有子视图, 都会被下移 64px。
这个下移 64px 的前提是 navigationBar 和 statusBar 没有隐藏。因为为 statusBar 默认的 Height 是 20px,而 navigatiBar 默认的 Height 是 44px。下面来比较一下
实例:
不使用导航的界面跳转
1. 在 AppDelegate.m 文件中:
Obj-c代码 收藏代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
//下面两行为增加的代码
ViewController *rootViewController = [[ViewController alloc] init];
[self.window setRootViewController:rootViewController];
[self.window make
ios7 导航控制器切换影响UIScrollView布局的问题
最新推荐文章于 2018-05-11 19:17:00 发布