为什么导航显示在视图中状态栏下方 20 像素处? [英] Why do navigation appear 20 pixels below status bar in the view?

查看:11
本文介绍了为什么导航显示在视图中状态栏下方 20 像素处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
iPad 上的 UIWebView 尺寸

- (void)viewDidLoad {

    [super viewDidLoad];

    UINavigationController *naviController = [[UINavigationController alloc]init];

    [self.view addSubview:naviController.view];

}

如果我在视图中添加导航控制器,它会出现在状态栏下方约 20 像素处.我希望它出现在状态栏下方.我该如何解决这个问题?

If I add navigation controller in the view, it appears about 20 pixels below status bar. I want it appears just below status bar. How do I fix this?

推荐答案

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    CGRect frame = CGRectMake(0, 0, 320.0, 480.0);
    viewController.view.frame = frame;
    [self.window addSubview:viewController.view];
    [self.window makeKeyAndVisible];

    return YES;
}

我像上面一样改变了.有用.到现在为止还挺好.如果高度为 460,则底部会有空白行.View 的绝对坐标是 (0, 20).因此,导航栏的坐标为 (0, 40).我认为这就是问题所在.我会遇到另一个问题.也许有办法在显示导航视图之前改变坐标.谢谢.

I changed like above. It works. So far so good. If height was 460, there would have been blank line at the bottom. View's absolute coordinate is (0, 20). So, Navigation bar's coordinate is (0, 40). I think that was the problem. I will encounter another problem. Maybe there is way to change coordinate before displaying navigation view. Thank you.

这篇关于为什么导航显示在视图中状态栏下方 20 像素处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆