Hello future friends who is gonna help me big time on this project,
I have these Books parsed from XML file (adopted from this post I found). First view (RootViewController) has a list of book titles in a UITable. When user clicks on one of the books, instead of viewing the books detail (BooksDetailViewController) in a second UITable, I would like the Title, Author and Summary to be in a custom view laid out in Interface Builder with UILabels and UITextView.
IBOutlet UILabel *bookTitle;
IBOutlet UILabel *bookAuthor;
IBOutlet UITextView *bookSummary;
I believe my problem has to do with RootViewController.m "didSelectRowAtIndexPath". If I understand the example I had adapted properly (which I am not confident about), it passed the Book array into each row of the new table on my BooksDetailViewController.
Book *aBook = [appDelegate.books objectAtIndex:indexPath.row];
I have tried a few things to recreate didSelectRowAtIndexPath, but I am not having much luck. Below I have the example code commented out and with my own terrible guessed code /sigh.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// if(bdvController == nil)
// bdvController = [[BookDetailViewController alloc] initWithNibName:@"BookDetailView" bundle:[NSBundle mainBundle]];
// Book *aBook = [appDelegate.books objectAtIndex:indexPath.row];
// bdvController.aBook = aBook;
// [self.navigationController pushViewController:bdvController animated:YES];
NewBookDetailViewController *detailViewController = [[NewBookDetailViewController alloc] initWithNibName:@"NewBookDetailViewController" bundle:nil];
Book *aBook = appDelegate.books;
//detailViewController.aBook.title = bookTitle.text;
//detailViewController.aBook.author = bookAuthor.text;
//detailViewController.aBook.summary = bookSummary.text;
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}
Do I actually connect the parsed data aBook.title to bookTitle (UILabel) in didSelectRowAtIndexPath of RootViewController?
or
Do I connect them in viewDidLoad in NewBookDetailViewController.m?
bookTitle.text = aBook.title;
bookAuthor.text = aBook.author;
bookSummary.text = aBook.summary;
What is the proper way to write the didSelectRowAtIndexPath in RootViewController for a custom view instead of a table view?
Please take it easy on me.
- Clo