mirror of
https://github.com/shuto-cn/cordova-plugin-inappbrowser.git
synced 2025-04-02 12:52:44 +08:00
fix 修复ios toolbar 完成按钮失效的问题
This commit is contained in:
parent
b8e87a8b1d
commit
694ffb52eb
@ -56,6 +56,7 @@
|
||||
NSDictionary *_settings;
|
||||
}
|
||||
|
||||
@property (nonatomic, strong) IBOutlet UIViewController* parent;
|
||||
@property (nonatomic, strong) IBOutlet WKWebView* webView;
|
||||
@property (nonatomic, strong) IBOutlet WKWebViewConfiguration* configuration;
|
||||
@property (nonatomic, strong) IBOutlet UIBarButtonItem* closeButton;
|
||||
@ -76,6 +77,6 @@
|
||||
- (void)showToolBar:(BOOL)show : (NSString *) toolbarPosition;
|
||||
- (void)setCloseButtonTitle:(NSString*)title : (NSString*) colorString : (int) buttonIndex;
|
||||
|
||||
- (id)initWithBrowserOptions: (CDVInAppBrowserOptions*) browserOptions andSettings:(NSDictionary*) settings;
|
||||
- (id)initWithBrowserOptions: (CDVInAppBrowserOptions*) browserOptions andSettings:(NSDictionary*) settings andParent:(UIViewController*) parent;
|
||||
|
||||
@end
|
||||
|
@ -74,11 +74,7 @@ static CDVWKInAppBrowser* instance = nil;
|
||||
NSLog(@"IAB.close() called but it was already closed.");
|
||||
return;
|
||||
}
|
||||
UIView *lastView;
|
||||
for(UIView *subview in [self.viewController.view subviews]) {
|
||||
lastView = subview;
|
||||
}
|
||||
[lastView removeFromSuperview];
|
||||
|
||||
// Things are cleaned up in browserExit.
|
||||
[self.inAppBrowserViewController close];
|
||||
}
|
||||
@ -203,7 +199,7 @@ static CDVWKInAppBrowser* instance = nil;
|
||||
}
|
||||
|
||||
if (self.inAppBrowserViewController == nil) {
|
||||
self.inAppBrowserViewController = [[CDVWKInAppBrowserViewController alloc] initWithBrowserOptions: browserOptions andSettings:self.commandDelegate.settings];
|
||||
self.inAppBrowserViewController = [[CDVWKInAppBrowserViewController alloc] initWithBrowserOptions: browserOptions andSettings:self.commandDelegate.settings andParent: self.viewController];
|
||||
self.inAppBrowserViewController.navigationDelegate = self;
|
||||
|
||||
if ([self.viewController conformsToProtocol:@protocol(CDVScreenOrientationDelegate)]) {
|
||||
@ -716,7 +712,7 @@ static CDVWKInAppBrowser* instance = nil;
|
||||
BOOL viewRenderedAtLeastOnce = FALSE;
|
||||
BOOL isExiting = FALSE;
|
||||
|
||||
- (id)initWithBrowserOptions: (CDVInAppBrowserOptions*) browserOptions andSettings:(NSDictionary *)settings
|
||||
- (id)initWithBrowserOptions: (CDVInAppBrowserOptions*) browserOptions andSettings:(NSDictionary *)settings andParent:(UIViewController*) parent
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
@ -724,7 +720,7 @@ BOOL isExiting = FALSE;
|
||||
_settings = settings;
|
||||
self.webViewUIDelegate = [[CDVWKInAppBrowserUIDelegate alloc] initWithTitle:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]];
|
||||
[self.webViewUIDelegate setViewController:self];
|
||||
|
||||
self.parent = parent;
|
||||
[self createViews];
|
||||
}
|
||||
|
||||
@ -1079,14 +1075,23 @@ BOOL isExiting = FALSE;
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)newClose{
|
||||
|
||||
}
|
||||
- (void)close
|
||||
{
|
||||
self.currentURL = nil;
|
||||
|
||||
__weak UIViewController* weakSelf = self;
|
||||
__weak UIViewController* weakParentSelf = self.parent;
|
||||
|
||||
// Run later to avoid the "took a long time" log message.
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
UIView *lastView;
|
||||
for(UIView *subview in [weakParentSelf.view subviews]) {
|
||||
lastView = subview;
|
||||
}
|
||||
[lastView removeFromSuperview];
|
||||
isExiting = TRUE;
|
||||
if ([weakSelf respondsToSelector:@selector(presentingViewController)]) {
|
||||
[[weakSelf presentingViewController] dismissViewControllerAnimated:YES completion:nil];
|
||||
|
Loading…
x
Reference in New Issue
Block a user