我在這裏提出質疑:Best idea for importing text to each NavigationController View回答我關於導航控制器的舊問題!
的回答是這樣的:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
PoemDetailsViewController *poemDetails = [[[PoemDetailsViewController alloc] initWithNibName:@"PoemDetailsViewController" bundle:nil] autorelease];
poemDetails.poem = [poems objectAtIndex:indexPath.row]; // assuming you have a single dimension array with poems and a single table group
[self.navigationController pushViewController:poemDetails animated:YES];
}
現在在PoemDetailsViewController我創建一個UIWebView並編寫這些代碼:
(我知道這個代碼只顯示一個我的HTML文件)
NSString *path = [[NSBundle mainBundle] pathForResource:@"fal1" ofType:@"html"];
NSFileHandle *readHandle = [NSFileHandle fileHandleForReadingAtPath:path];
NSString *htmlString = [[NSString alloc] initWithData:
[readHandle readDataToEndOfFile] encoding:NSUTF8StringEncoding];
現在我找不到任何關聯此代碼
poemDetails.poem = [poems objectAtIndex:indexPath.row];
在每個單元格上加載AnotherViewController上的詩嗎?
我的意思是每個細胞都用導航控制器在其他視圖上顯示他們的詩。
是否有一個理由,爲什麼你不使用'NSString.stringWithContentsOfFile:編碼:錯誤:'? – notnoop 2010-01-06 22:26:20
我有495個電池,所以他們進口plist財產! NSString * myfile = [[NSBundle mainBundle] pathForResource:@「ghazal」ofType:@「plist」]; \t ghazalList = [[NSArray alloc] initWithContentsOfFile:myfile]; 和: - (NSInteger的)的tableView:(UITableView的*)的tableView numberOfRowsInSection:(NSInteger的)部分 { \t返回ghazalList.count; } 等 (爲什麼評論沒有代碼標記!?) – Momi 2010-01-06 22:36:49
@notnoop:對不起IAM新iPhone的SDK – Momi 2010-01-06 22:41:45