簡體   English   中英

iOS,導航欄與其內容視圖重疊

[英]ios, navigationbar is overlapped with its content view

我正在呈現一個如下所示的viewcontroller,並且所呈現的view controller的內容與它自己的導航欄重疊。

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調整到整個屏幕-導航欄-狀態欄。 (當我pushedViewController時效果很好)

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

在此處輸入圖片說明在此處輸入圖片說明

請在viewDidLoad方法中添加以下行:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM