<legend id='qN8Xe'><style id='qN8Xe'><dir id='qN8Xe'><q id='qN8Xe'></q></dir></style></legend>
    <bdo id='qN8Xe'></bdo><ul id='qN8Xe'></ul>

    <small id='qN8Xe'></small><noframes id='qN8Xe'>

      1. <tfoot id='qN8Xe'></tfoot>

        <i id='qN8Xe'><tr id='qN8Xe'><dt id='qN8Xe'><q id='qN8Xe'><span id='qN8Xe'><b id='qN8Xe'><form id='qN8Xe'><ins id='qN8Xe'></ins><ul id='qN8Xe'></ul><sub id='qN8Xe'></sub></form><legend id='qN8Xe'></legend><bdo id='qN8Xe'><pre id='qN8Xe'><center id='qN8Xe'></center></pre></bdo></b><th id='qN8Xe'></th></span></q></dt></tr></i><div id='qN8Xe'><tfoot id='qN8Xe'></tfoot><dl id='qN8Xe'><fieldset id='qN8Xe'></fieldset></dl></div>

        UIWebView 在 iOS 8 中显示空白屏幕

        时间:2023-10-21

            <bdo id='bq8FE'></bdo><ul id='bq8FE'></ul>
            <i id='bq8FE'><tr id='bq8FE'><dt id='bq8FE'><q id='bq8FE'><span id='bq8FE'><b id='bq8FE'><form id='bq8FE'><ins id='bq8FE'></ins><ul id='bq8FE'></ul><sub id='bq8FE'></sub></form><legend id='bq8FE'></legend><bdo id='bq8FE'><pre id='bq8FE'><center id='bq8FE'></center></pre></bdo></b><th id='bq8FE'></th></span></q></dt></tr></i><div id='bq8FE'><tfoot id='bq8FE'></tfoot><dl id='bq8FE'><fieldset id='bq8FE'></fieldset></dl></div>

            <tfoot id='bq8FE'></tfoot>
            • <legend id='bq8FE'><style id='bq8FE'><dir id='bq8FE'><q id='bq8FE'></q></dir></style></legend>
                  <tbody id='bq8FE'></tbody>
                1. <small id='bq8FE'></small><noframes id='bq8FE'>

                2. 本文介绍了UIWebView 在 iOS 8 中显示空白屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个应用程序,我可以在其中下载 pdf 并将其存储在 iPhone 中.它在 iOS 7 中运行良好(我目前在 iOS 8 上运行)并且在 iOS 8 中运行应用程序时,webView 只是保持空白.我不知道出了什么问题.

                  I have an app where I can download a pdf and store it in the iPhone. It worked perfectly in iOS 7 (I am currently running on iOS 8) and while running the app in iOS 8, the webView just stays blank. I have I no idea what's wrong.

                  #import "ISJMMisalViewController.h"
                  #import "SWRevealViewController.h"
                  
                  @implementation ISJMMisalViewController
                  @synthesize activityImageView;
                  
                  - (void)viewWillAppear:(BOOL)animated {
                      [super viewWillAppear:YES];
                  
                      [self.webView addSubview:activityImageView];
                      [activityImageView startAnimating];
                  
                      dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                  
                          NSString *resourceDocPath = [[NSString alloc] initWithString:[[[[NSBundle mainBundle] resourcePath]stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"Documents"]];
                          NSString *filePath = [resourceDocPath stringByAppendingPathComponent:@"misalLocal.pdf"];
                  
                          //Now create Request for the file that was saved in your documents folder
                          NSURL *url = [NSURL fileURLWithPath:filePath];
                          NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
                  
                          dispatch_async(dispatch_get_main_queue(), ^{
                  
                              [self.webView setUserInteractionEnabled:YES];
                              [self.webView setDelegate:self];
                              [self.webView loadRequest:requestObj];
                              [self.webView setScalesPageToFit:YES];
                              [activityImageView stopAnimating];
                              [activityImageView removeFromSuperview];
                  
                          });
                      });
                  
                  }
                  
                  - (void)viewDidLoad {
                      [super viewDidLoad];
                  
                      [self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
                  
                      UIImage *image = [UIImage imageNamed: @"NavBarImage.png"];
                      UIImageView *imageView = [[UIImageView alloc] initWithImage: image];
                  
                      self.navigationItem.titleView = imageView;
                  
                      _sidebarButton.target = self.revealViewController;
                      _sidebarButton.action = @selector(revealToggle:);
                  
                      //Create the first status image and the indicator view
                      UIImage *statusImage = [UIImage imageNamed:@"1.png"];
                      activityImageView = [[UIImageView alloc] initWithImage:statusImage];
                  
                  
                      //Add more images which will be used for the animation
                      activityImageView.animationImages = [NSArray arrayWithObjects:
                                                           [UIImage imageNamed:@"1.png"],
                                                           [UIImage imageNamed:@"2.png"],
                                                           [UIImage imageNamed:@"3.png"],
                                                           [UIImage imageNamed:@"4.png"],
                                                           [UIImage imageNamed:@"5.png"],
                                                           [UIImage imageNamed:@"6.png"],
                                                           [UIImage imageNamed:@"7.png"],
                                                           [UIImage imageNamed:@"8.png"],
                                                           [UIImage imageNamed:@"9.png"],
                                                           nil];
                  
                  
                      //Set the duration of the animation (play with it
                      //until it looks nice for you)
                      activityImageView.animationDuration = 0.7;
                  
                  
                      //Position the activity image view somewhere in
                      //the middle of your current view
                      activityImageView.frame = CGRectMake(self.view.frame.size.width/2 - 50, self.view.frame.size.height/2 - 100, 100, 100);
                  
                      UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toggleNavBar:)];
                      [self. webView addGestureRecognizer:gesture];
                  
                      if (!self.webView) {
                  
                          UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sin conexión"
                                                                          message:@"No fue posible la descarga de datos debido a que no se pudo conectar con el servidor"
                                                                         delegate: nil
                                                                cancelButtonTitle: @"OK"
                                                                otherButtonTitles: nil];
                  
                          [alert show];
                  
                      }
                  
                  
                  }
                  
                  - (IBAction)actualizar:(id)sender {
                  
                      [self.webView addSubview:activityImageView];
                      [activityImageView startAnimating];
                  
                      dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                  
                          NSData *pdfData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://isjm.weebly.com/uploads/2/5/3/6/25368636/misal.pdf"]];
                          NSString *resourceDocPath = [[NSString alloc] initWithString:[[[[NSBundle mainBundle] resourcePath]stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"Documents"]];
                          NSString *filePath = [resourceDocPath stringByAppendingPathComponent:@"misalLocal.pdf"];
                          [pdfData writeToFile:filePath atomically:YES];
                  
                          NSURL *url = [NSURL fileURLWithPath:filePath];
                          NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
                  
                          dispatch_async(dispatch_get_main_queue(), ^{
                  
                              [self.webView setUserInteractionEnabled:YES];
                              [self.webView setDelegate:self];
                              [self.webView loadRequest:requestObj];
                              [self.webView setScalesPageToFit:YES];
                              [activityImageView stopAnimating];
                              [activityImageView removeFromSuperview];
                  
                              if (!self.webView) {
                  
                                  UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sin conexión"
                                                                                  message:@"No fue posible la descarga de datos debido a que no se pudo conectar con el servidor"
                                                                                 delegate: nil
                                                                        cancelButtonTitle: @"OK"
                                                                        otherButtonTitles: nil];
                  
                                  [alert show];
                              }
                          });
                      });
                  }
                  
                  - (void)toggleNavBar:(UITapGestureRecognizer *)gesture {
                  
                      BOOL barsHidden = self.navigationController.navigationBar.hidden;
                      [self.navigationController setNavigationBarHidden:!barsHidden animated:YES];
                  
                  }
                  
                  - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
                  {
                      return YES;
                  }
                  
                  @end
                  

                  推荐答案

                  这是 iOS 8 的 bug!您可以使用以下方法解决它:

                  It's an iOS 8 bug! You can work around it using:

                  NSString *string = [[NSBundle mainBundle] pathForResource:@"Low Cost Perimeter Build Guide" ofType:@"pdf"];
                  NSURL *url = [NSURL fileURLWithPath:string];
                  NSData *pdfData = [[NSData alloc] initWithContentsOfURL:url];
                  [self.webView loadData:pdfData MIMEType:@"application/pdf" textEncodingName:@"utf-8" baseURL:nil];
                  

                  这篇关于UIWebView 在 iOS 8 中显示空白屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:我可以使用 Javascript(或任何 Web 技术)将 UIWebView 中的变量传递回我的应用程序吗? 下一篇:将 NSData 加载到 UIWebView

                  相关文章

                3. <small id='9rpHt'></small><noframes id='9rpHt'>

                    <tfoot id='9rpHt'></tfoot>

                    • <bdo id='9rpHt'></bdo><ul id='9rpHt'></ul>

                    1. <i id='9rpHt'><tr id='9rpHt'><dt id='9rpHt'><q id='9rpHt'><span id='9rpHt'><b id='9rpHt'><form id='9rpHt'><ins id='9rpHt'></ins><ul id='9rpHt'></ul><sub id='9rpHt'></sub></form><legend id='9rpHt'></legend><bdo id='9rpHt'><pre id='9rpHt'><center id='9rpHt'></center></pre></bdo></b><th id='9rpHt'></th></span></q></dt></tr></i><div id='9rpHt'><tfoot id='9rpHt'></tfoot><dl id='9rpHt'><fieldset id='9rpHt'></fieldset></dl></div>
                      <legend id='9rpHt'><style id='9rpHt'><dir id='9rpHt'><q id='9rpHt'></q></dir></style></legend>