Skip to content

Commit

Permalink
优化当作为navigationController的根视图时的显示问题。
Browse files Browse the repository at this point in the history
  • Loading branch information
pcjbird committed Jan 9, 2018
1 parent f9fd01d commit 6e57a98
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 5 deletions.
2 changes: 1 addition & 1 deletion QuickWebKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "QuickWebKit"
s.version = "1.0.6"
s.version = "1.0.7"
s.summary = "A great & strong plugin based WebViewController. 一款基于插件的 WebView 视图控制器,您可以基于它设计您的浏览器插件,然后像积木一样来组装它们。"
s.description = <<-DESC
A great & strong plugin based WebViewController. 一款基于插件的 WebView 视图控制器,您可以基于它设计您的浏览器插件,然后像积木一样来组装它们。
Expand Down
47 changes: 44 additions & 3 deletions QuickWebKit/QuickWebCore/QuickWebViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ -(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:_navbarTransparent animated:animated];
if([self.navigationController.viewControllers firstObject] != self)
{
self.hidesBottomBarWhenPushed = YES;
}
if([self.pauseResumeEventListenObject isKindOfClass:[QuickWebPauseResumeEventObject class]] && self.pauseResumeEventListenObject.resultHandler)
{
[self.pauseResumeEventListenObject.resultHandler handleQuickWebJSInvokeResult:[self.pauseResumeEventListenObject toResultWithSecretId:_contentWebView.secretId event:QuickWebPauseResumeEvent_Resume]];
Expand Down Expand Up @@ -230,7 +234,6 @@ -(void)didPushedToNextVC:(BOOL)animated
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.hidesBottomBarWhenPushed = YES;
self.edgesForExtendedLayout = UIRectEdgeAll;
self.extendedLayoutIncludesOpaqueBars = NO;
if([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0 && [[[UIDevice currentDevice] systemVersion] floatValue] < 11.0)
Expand Down Expand Up @@ -376,6 +379,10 @@ -(void) goBack:(id)sender
if([_contentWebView isKindOfClass:[SmartJSWebView class]] && [_contentWebView canGoBack])
{
[_contentWebView goBack];
weak(weakSelf);
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[weakSelf updateLeftBarButtonItems];
});
}
else
{
Expand Down Expand Up @@ -648,9 +655,20 @@ - (UIBarButtonItem *)closeItem
#pragma mark - 更新导航左侧按钮
-(void) updateLeftBarButtonItems
{
if(_contentWebView && [_contentWebView canGoBack])
if(![_contentWebView isKindOfClass:[SmartJSWebView class]]) return;
if([_contentWebView canGoBack])
{
self.navigationItem.leftBarButtonItems = @[self.backItem, self.closeItem];
UINavigationController *naviContoller = self.navigationController;
if([naviContoller isKindOfClass:[UINavigationController class]])
{
UIViewController * rootViewController = [naviContoller.viewControllers firstObject];
if(rootViewController != self)
{
self.navigationItem.leftBarButtonItems = @[self.backItem, self.closeItem];
return;
}
}
self.navigationItem.leftBarButtonItems = @[self.backItem];
}
else
{
Expand Down Expand Up @@ -1024,16 +1042,39 @@ -(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)r
-(void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation
{
ShowNetworkActivityIndicator();
weak(weakSelf);
[_pluginMap enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull key, id<QuickWebPluginProtocol> _Nonnull obj, BOOL * _Nonnull stop) {
if([obj respondsToSelector:@selector(webViewControllerDidStartLoad:)])
{
[obj webViewControllerDidStartLoad:weakSelf];
}
}];
}

-(void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
{
HideNetworkActivityIndicator();
[self updateLeftBarButtonItems];
self.navigationItem.title = _contentWebView.title;
weak(weakSelf);
[_pluginMap enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull key, id<QuickWebPluginProtocol> _Nonnull obj, BOOL * _Nonnull stop) {
if([obj respondsToSelector:@selector(webViewControllerDidFinishLoad:)])
{
[obj webViewControllerDidFinishLoad:weakSelf];
}
}];
}

-(void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error
{
HideNetworkActivityIndicator();
weak(weakSelf);
[_pluginMap enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull key, id<QuickWebPluginProtocol> _Nonnull obj, BOOL * _Nonnull stop) {
if([obj respondsToSelector:@selector(webViewController:didFailLoadWithError:)])
{
[obj webViewController:weakSelf didFailLoadWithError:error];
}
}];
}

#pragma mark - Status Bar
Expand Down
3 changes: 3 additions & 0 deletions QuickWebKit/QuickWebKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
// 框架名称:QuickWebKit
// 框架功能:A great & strong plugin based WebViewController. 一款基于插件的 WebView 视图控制器,您可以基于它设计您的浏览器插件,然后像积木一样来组装它们。
// 修改记录:
// pcjbird 2018-01-07 Version:1.0.7 Build:201801090001
// 1.优化当作为navigationController的根视图时的显示问题。
//
// pcjbird 2018-01-06 Version:1.0.6 Build:201801060001
// 1.修复Share插件与Spotlight插件导致Crash的问题。
//
Expand Down
2 changes: 1 addition & 1 deletion QuickWebKit/Supporting Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.6</string>
<string>1.0.7</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down

0 comments on commit 6e57a98

Please sign in to comment.