Do I need an iPhone / iPad UIWebView for active viewing?

I need to display a webpage on screen in a bitmap and then show the bitmap for the user. This can be done using simple code in the main thread, for example:

NSString *urlAddress = @"http://www.google.com"; NSURL *url = [NSURL URLWithString:urlAddress]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; [offscreenWebView loadRequest:requestObj]; 

Or do I need to connect the UIWebView to the active view?

In Android, the web view does not seem to be displayed unless it is part of the active view. Therefore, to complete this task in Android, I need to create a hierarchy of views, create an active view for the web renderer, and then add another top view so that it can display the screen.

+4
source share
1 answer

I struggled with this problem for a while. UIWebView will not be displayed if it is not added to the UIWindow object. However, this should not be the window that you use to display your application. You can create a separate UIWindow object and attach a UIWebView to it, and it will display just fine. However, rendering UIWebView is a slow process, so it will have a slight delay before it is ready. When this is done, he will call the webViewDidFinishLoad method for his delegate.

+5
source

Source: https://habr.com/ru/post/1403248/


All Articles