开发者

answer to my old question about navigation Controller !

开发者 https://www.devze.com 2022-12-15 20:33 出处:网络
i had questionedhere : Best idea for importing text to each NavigationController View the answer was this:

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"];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号