Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] WebView keeps loading forever in case Add2App #344

Closed
hnvn opened this issue Mar 9, 2019 · 1 comment
Closed

[iOS] WebView keeps loading forever in case Add2App #344

hnvn opened this issue Mar 9, 2019 · 1 comment

Comments

@hnvn
Copy link
Member

hnvn commented Mar 9, 2019

I encountered this matter yesterday and it took me a day to fix it. At first, I think it relates to Info.plist configuration, something like App Transport Security, but it is not my case. In my case, my application works well as a Flutter standard alone application but when I add it to my existing application, my WebView keeps showing loading state forever.

Try to debug it in Xcode and here is what I've found: The plugin uses rootViewController as the current visible ViewController, it only works in case the application has only one ViewController, but in case of Add2App, the application has many ViewController, our FlutterViewController is one of them. By using the wrong ViewController, the following code doesn't work:

[self.viewController.view addSubview:self.webview];

The result is that WKWebView has never been attached to the current ViewController (a FlutterViewController in this case) and the UI shows loading forever.

Here's my solution to solve this matter:

UIViewController* presentedViewController = self.viewController.presentedViewController;
UIViewController* currentViewController = presentedViewController != nil ? presentedViewController : self.viewController;
[currentViewController.view addSubview:self.webview];

Hope that it is useful.

@hnvn
Copy link
Member Author

hnvn commented Mar 24, 2019

fixed in #292

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant