这里有2个视图:
- WelcomeVC
- WebViewVC
AppDelegate 首先通过以下代码调用 WelcomeVC:
- (void)presentWelcomeViewController
WelcomeViewController *welcomeViewController = [[WelcomeViewController alloc] initWithNibName:@"WelcomeViewController" bundle:nil];
welcomeViewController.title = @"Welcome to My App";
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:welcomeViewController];
navController.navigationBarHidden = YES;
self.viewController = navController;
self.window.rootViewController = self.viewController;
}
在WelcomeVC中,导航栏不会显示,可以使用navController.navigationBarHidden = YES;
。在WelcomeVC中,有一个按钮可以调用以下详细信息的WebViewVC:
- (IBAction)termsPressed:(id)sender {
WebViewController *webViewController = [[WebViewController alloc] initWithNibName:nil bundle:nil];
NSLog(@"Terms of Use");
webViewController.urlPassed = @"http://.../term.html";
webViewController.title = NSLocalizedString(@"Terms of Use", nil);
[webViewController.navigationController setNavigationBarHidden:NO animated:NO];
[self.navigationController presentViewController:webViewController animated:YES completion:^{}];
}
当按下此按钮时,我希望它调用 WebViewVC,并像这样呈现导航栏:
[webViewController.navigationController setNavigationBarHidden:NO animated:NO];
但是我发现 WebViewVC 仍然没有呈现导航栏。我还在 WebViewVC 中包含了以下内容:viewDidLoad
。- (void)viewDidLoad {
[super viewDidLoad];
CGSize screenSize = [[UIScreen mainScreen] bounds].size;
if(screenSize.height == 480)
{
webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
}
else if(screenSize.height == 568)
{
webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 568)];
}
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlPassed]]];
[self.view addSubview:webView];
}
请问有人能帮我指出哪里错了或者做错了吗?非常感谢。提前致谢!