在任何ViewController上加载后台(不可见)的UIWebView



我想在后台加载一个UIWebView,这样它就不会从用户那里获取任何输入,也不会让用户看到它。当我需要加载UIWebView时,我也不知道用户会在什么视图中,我不想复制/粘贴我的代码在我所有的viewcontroller中。我该怎么做呢?

我通过调用http请求来解决这个问题,使用以下方法:

NSURL *url = [NSURL URLWithString:url];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
[NSURLConnection sendAsynchronousRequest:urlRequest queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error){
            if (error)
            {
               NSLog(@"Error,%@", [error localizedDescription]);
            }
            else
           {
              NSLog(@"1");
           }
}];

最新更新