【问题标题】:Trouble loading a local HTML file in UIWebView在 UIWebView 中加载本地 HTML 文件时遇到问题
【发布时间】:2012-09-06 13:25:13
【问题描述】:

我正在尝试从我的项目中的支持​​文件夹中加载本地 HTML 文件...我不断收到此消息...线程 1:断点 1.1,我不知道为什么,我的网络代码视图如下

#import "WPViewController.h"

@interface UIViewController ()

@end

@implementation WPViewController

@synthesize viewWeb;

- (void)viewDidLoad {

[super viewDidLoad];
NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"  inDirectory:@"localHTML"];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[viewWeb loadRequest:request];
}

 - (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

- (IBAction)dismissView:(id)sender {
[self dismissModalViewControllerAnimated:YES];
}

@end

标题...

#import <UIKit/UIKit.h>

@interface WPViewController : UIViewController

@property (strong, nonatomic) IBOutlet UIWebView *viewWeb;

- (IBAction)dismissView:(id)sender;

@end

【问题讨论】:

    标签: iphone html ios xcode uiwebview


    【解决方案1】:

    首先,请仔细检查您没有设置任何停止应用程序的断点。您可以使用 CMD+Y 禁用/启用它们。此外,您可以查看是否在左侧窗格 -> Breakpoint Navigator 选项卡上设置了任何内容。

    另外,你应该尝试实现UIWebViewDelegate 协议并覆盖

    - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
    

    在您的 WPViewController 中,以便您可以获取有关页面未显示原因的更多信息。

    【讨论】:

      【解决方案2】:

      试试可能对你有帮助..

      - (void)viewDidLoad {
      
      [super viewDidLoad];
      
      NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"html_files"];
      
      NSData *htmlData = [NSData dataWithContentsOfFile:htmlFile];
      webView = [UIWebView alloc] init];
      [webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:[NSURL URLWithString:@""]];
      
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-01-18
        • 2012-12-08
        • 2011-01-02
        • 2011-06-06
        • 2011-10-27
        相关资源
        最近更新 更多