2013-07-09 40 views
-1

我有此錯誤:在ios中添加HTML路徑時出現錯誤

「沒有可見的@interface for'NSBundle聲明selector'pathforresource:類型」。

#import "ViewController.h" 

@interface ViewController() 

@end 

@implementation ViewController 

@synthesize WebView1; 
- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 
    NSString *localFilePath = [[NSBundle mainBundle] pathForResoursce:@"www/index" ofType:@"html"] ; 
    NSURLRequest *localRequest = [NSURLRequest requestWithURL: 
            [NSURL fileURLWithPath:localFilePath]] ; 

    [WebView1 loadRequest:localRequest] ; 

} 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

@end 


#import <UIKit/UIKit.h> 
#import "ViewController.h" 
@interface ViewController : UIViewController 

@property (nonatomic,retain) IBOutlet UIWebView *WebView1; 

@end 
+2

你進口的基礎呢? – johnyu

+0

你是什麼意思進口的基礎? – Myworld

+0

「#import 」 – johnyu

回答

2

檢查,因爲你拼錯了函數的名稱:

NSString *localFilePath = [[NSBundle mainBundle] pathForResoursce:@"www/index" ofType:@"html"] ; 

應該是:

NSString *localFilePath = [[NSBundle mainBundle] pathForResource:@"www/index" ofType:@"html"] ; 

然後檢查HTML文件的名稱。它可能是index.html

如果在發現問題的困難,你說pathForResoursce:代替pathForResource:

+0

我沒有發現任何變化你的兩個代碼之間的差異 – Myworld

+0

@nemoz:你應該投資一些眼鏡;)提示:資源 – HAS

+0

Resoursce已更改到資源 – johnyu

相關問題