0

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

#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
4

2 回答 2

1

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

此外,您应该尝试实现UIWebViewDelegate协议并覆盖

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

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

于 2012-09-06T16:50:44.673 回答
0

尝试可能会帮助你..

- (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:@""]];

}
于 2012-09-06T13:34:43.017 回答