我正在尝试从我的项目中的支持文件文件夹加载本地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
答案 0 :(得分:1)
首先,仔细检查您是否未设置任何停止应用的断点。您可以使用CMD + Y禁用/启用它们。此外,您可以在左窗格中查看是否已设置任何内容 - &gt;断点导航器选项卡。
此外,您应该尝试实施UIWebViewDelegate协议并覆盖
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
在WPViewController中,这样您就可以获得有关页面未显示原因的更多信息。
答案 1 :(得分: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:@""]];
}