ios,导航栏与其内容视图重叠

时间:2014-10-27 03:34:29

标签: ios iphone uinavigationcontroller

我正在展示如下所示的viewcontroller,并且呈现的视图控制器的内容与其自己的导航栏重叠。

MyViewController *myViewController = [[MyViewController alloc] initWithNibName:nil bundle:nil];
UINavigationController *navigationController = 
    [[UINavigationController alloc] initWithRootViewController:myViewController];

//now present this navigation controller modally 
[self presentViewController:navigationController
                   animated:YES
                   completion:^{

                        }];

我可以通过调整contentView的帧原点/大小来修复它,但有更简单的方法吗?

self.webview是contentview,我曾经使用以下代码使webview适合整个屏幕 - navigationbar - statusbar。 (当我只是pushedViewController时)效果很好

self.webview.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
[self.view addSubview:self.webview];
self.webview.frame = self.webview.superview.bounds;

enter image description here enter image description here

1 个答案:

答案 0 :(得分:0)

请在viewDidLoad方法中添加以下内容:

self.navigationController.navigationBar.translucent = YES; 
self.edgesForExtendedLayout = UIRectEdgeNone;