NSBundle *thisBundleb = [NSBundle mainBundle];
pathb = [thisBundleb pathForResource:[a3 objectAtIndex:0] ofType:@"html"];
NSURL *instructionsURLb = [[NSURL alloc] initFileURLWithPath:pathb];
[webView loadRequest:[NSURLRequest requestWithURL:instructionsURLb]];
我做错了什么?
答案 0 :(得分:1)
您的index.html
实际上是Index.html
吗?我相信pathForResource:ofType
区分大小写。
答案 1 :(得分:1)
pathForResource:ofType:返回nil,而initFileURLWithPath:正在抱怨它。陷阱那样的错误:
if(nil == pathb) {
NSLog("Couldn't find object named %@", [a3 objectAtIndex:0]);
} else {
NSURL *instructionsURLb = [[NSURL alloc] initFileURLWithPath:pathb];
[webView loadRequest:[NSURLRequest requestWithURL:instructionsURLb]];
}
并仔细检查您是否正在搜索捆绑包中实际存在的对象。