Browse Source

fix bugs WebView doesn't show in iOS (Add2App)

Ha Duy Hung 6 years ago
parent
commit
4a2389a5f1
2 changed files with 5 additions and 3 deletions
  1. 3 1
      ios/Classes/FlutterWebviewPlugin.m
  2. 2 2
      lib/src/base.dart

+ 3 - 1
ios/Classes/FlutterWebviewPlugin.m

@@ -124,7 +124,9 @@ static NSString *const CHANNEL_NAME = @"flutter_webview_plugin";
 
     _enableZoom = [withZoom boolValue];
 
-    [self.viewController.view addSubview:self.webview];
+    UIViewController* presentedViewController = self.viewController.presentedViewController;
+    UIViewController* currentViewController = presentedViewController != nil ? presentedViewController : self.viewController;
+    [currentViewController.view addSubview:self.webview];
 
     [self navigate:call];
 }

+ 2 - 2
lib/src/base.dart

@@ -95,8 +95,8 @@ class FlutterWebviewPlugin {
   /// - [scrollBar]: enable or disable scrollbar
   /// - [supportMultipleWindows] enable multiple windows support in Android
   /// - [invalidUrlRegex] is the regular expression of URLs that web view shouldn't load.
-  /// For example, when web view is redirected to a specific URL, you want to intercept
-  /// this process by stopping loading this URL and replacing web view by another screen.
+  /// For example, when webview is redirected to a specific URL, you want to intercept
+  /// this process by stopping loading this URL and replacing webview by another screen.
   Future<Null> launch(String url, {
     Map<String, String> headers,
     bool withJavascript,