2011-10-23 29 views
0

我正在學習編寫iOS本機webkit應用程序。在Xcode 3.x中,我曾經的index.html分佈在資源文件夾,下面的代碼工作正常:當我創建的Xcode 4.2項目爲什麼路徑在Xcode 4.2中不起作用?

- (void)viewDidUnload 
{ 
    [super viewDidUnload]; 
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]; 
    NSData *htmlData = [NSData dataWithContentsOfFile:filePath]; 
    if (htmlData) 
    { 
     NSBundle *bundle = [NSBundle mainBundle]; 
     NSString *path = [bundle bundlePath]; 
     NSString *fullPath = [NSBundle pathForResource:@"index" ofType:@"html" inDirectory:path]; 
     [webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:fullPath]]]; 
    } 
} 

中的index.html沒有加載。我在「支持文件」文件夾中有index.html。我錯過了什麼嗎?請幫忙。

感謝

阿德里安

+0

對不起。該函數應該是viewDidLoad,而不是viewDidUnload。 –

+1

您可以發佈這個答案並將其標記爲正確的以關閉該問題 –

+0

對不起。這是我在這裏的第一篇文章,但我正在學習。謝謝你的耐心。 –

回答

1

這是我的疏忽。該函數應該是viewDidLoad,而不是viewDidUnload。

謝謝。

相關問題