-1

我有这个错误:

“'NSBundle 没有可见的@interface 声明选择器'pathforresource: of type”。

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

1 回答 1

3

检查函数的名称,因为您拼写错误:

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

应该 :

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

然后检查 html 文件的名称。可能是index.html

如果您很难找到您所说的问题pathForResoursce:而不是pathForResource:

于 2013-07-09T14:31:25.173 回答