2013-07-02 31 views
0

這裏我正在嘗試應用程序, 當我點擊表格視圖時,它將重定向到另一個稱爲細節的頁面。那裏我使用了一個webview來顯示選定的url值。 這裏是我的代碼如何在xcode中使用數組傳遞本地html文件

-(void)viewWillAppear:(BOOL)animated{ 
    [super viewWillAppear:YES]; 

    [email protected]"sample"; 
    servicesArray=[[NSMutableArray alloc]init]; 
    [servicesArray addObject:@"1"]; 
    [servicesArray addObject:@"2"]; 
    [servicesArray addObject:@"3"]; 

    urlsArray=[[NSMutableArray alloc]init]; 
    [urlsArray addObject:@"http://www.google.com"]; 
    [urlsArray addObject:@"http://www.yahoo.com"]; 
    [urlsArray addObject:@"http://www.facebook.com"]; 


} 

在這裏,而不是網址與我想通過我的本地HTML文件。你能請我幫忙嗎

謝謝 chintu。

回答

0

嘗試像這樣,取出Array yourArray中的所有html文件名。

NSString *htmlFile = [[NSBundle mainBundle] pathForResource:[yourArray objectAtIndex:selectedIndex] ofType:@"html" inDirectory:nil]; 
NSString* htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil]; 
[WebView loadHTMLString:htmlString baseURL:nil]; 
+0

但這是給我錯誤的第一行的代碼... – user2542055

+0

@ user2542055:它是什麼? – Balu

+0

4errors 聲明結束時預期':' 消息發送表達式開始處缺少'[' 未聲明標識符'htmlArray'的使用 – user2542055

相關問題