我在测试项目中正在使用webview,无法理解为什么在webview完成加载请求后导航栏会崩溃。 Looks weird 这是我的test project和ViewController的实现:
#import "ViewController.h"
@import WebKit;
@interface ViewController () <UIScrollViewDelegate, WKUIDelegate, WKNavigationDelegate>
@property (weak, nonatomic) IBOutlet WKWebView *webView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self setupNavigationBarView];
[self setupWebView];
}
- (void)setupWebView {
self.webView.scrollView.delegate = self;
self.webView.navigationDelegate = self;
self.webView.UIDelegate = self;
NSURL *url = [NSURL URLWithString:@"https://www.apple.com"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:request];
}
- (void)setupNavigationBarView {
self.title = @"Why nav. bar collapse?";
self.navigationController.navigationBarHidden = NO;
if (@available(iOS 11, *)) {
self.navigationController.navigationBar.prefersLargeTitles = YES;
}
self.navigationController.navigationBar.translucent = NO;
}
@end
如果您有任何帮助或建议,我将不胜感激,如果我的问题确实不是真的,我很抱歉-我是编程新手。