2012-09-06 89 views
0

我試圖從我的項目中的支持​​文件文件夾中加載本地HTML文件...我不斷收到此消息...線程1:斷點1.1,我不知道爲什麼,我對Web視圖代碼如下在UIWebView中加載本地HTML文件時遇到問題

#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 

回答

1

首先,仔細檢查你沒有設置任何停止你的應用程序的斷點。您可以使用CMD + Y來禁用/啓用它們。此外,您可以查看是否在左側窗格 - >「斷點導航器」選項卡上設置了任何設置。

此外,你應該儘量實現UIWebViewDelegate協議,並在您的WPViewController覆蓋

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

這樣你就可以得到,爲什麼沒有顯示在網頁一些更多的信息。

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

} 
相關問題