answer to my old question about navigation Controller !
i had questioned here : Best idea for importing text to each NavigationController View
the answer was this:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
PoemDetailsViewController *poemDetails = [[[PoemDetailsViewController alloc] i开发者_如何转开发nitWithNibName:@"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];
}
now on on the PoemDetailsViewController i create an UIWebView and writing this code :
(i know this code shows only one of my HTML files)
NSString *path = [[NSBundle mainBundle] pathForResource:@"fal1" ofType:@"html"];
NSFileHandle *readHandle = [NSFileHandle fileHandleForReadingAtPath:path];
NSString *htmlString = [[NSString alloc] initWithData:
[readHandle readDataToEndOfFile] encoding:NSUTF8StringEncoding];
now i can't find any associating between this code
poemDetails.poem = [poems objectAtIndex:indexPath.row];
to load poems on the AnotherViewController with each cell ?
i mean is every cells show their poem on the other view with Navigation Controller .
The line in question:
poemDetails.poem = [poems objectAtIndex:indexPath.row];
is simply passing information about the row (poem) that was selected to the new view controller.
Typically, the "poem" will be a custom class with relevant info about the poem such as its title and the name of its HTML file, but it could just be a string (if the title & HTML filename match).
For example, you would use it here:
NSString *path = [[NSBundle mainBundle] pathForResource:poem.filename ofType:@"html"];
精彩评论