Wrox Programmer Forums
|
BOOK: Beginning iPad Application Development
This is the forum to discuss the Wrox book Beginning iPad Application Development by Wei-Meng Lee; ISBN: 9780470641651
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning iPad Application Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 20th, 2011, 10:16 AM
Registered User
 
Join Date: Feb 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Question Question about chapter 7 tableview

I did the example for chapter 7 and it worked like the example. But I realized that I wanted to show the movie name in the Title, not "Item 1" which is what I am seeing now with
navigationBar.topItem.title = [detailItem description];

and It would be even better to print the year, is there any easy way of accessing the array name?
 
Old February 20th, 2011, 12:44 PM
Friend of Wrox
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

To get the title displayed in the detailview replace in
RootViewController.m

Code:
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
detailViewController.detailItem = [NSString stringWithFormat:@"Row %d", indexPath.row];
with
detailViewController.detailItem = [[[aTableView cellForRowAtIndexPath:indexPath] textLabel] text];

See if you can work out displaying the year. If not, I'll post it later.

Bob
 
Old February 20th, 2011, 09:09 PM
Registered User
 
Join Date: Feb 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks that was exactly what I was looking for.

For the year I added a new ID value, called detailYear and set it as follows.

detailViewController.detailYear = [sectionTitle objectAtIndex:[indexPath section]];

the odd thing is I seem to be getting the year of the previously selected item.
 
Old February 21st, 2011, 12:53 AM
Friend of Wrox
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

In RootViewController.m
Code:
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {	NSString *theTitle = [[[aTableView cellForRowAtIndexPath:indexPath] textLabel] text];
	NSString *theYear;
	if (isSearchOn) {
		theYear = @"";
	}else {
		theYear = [years objectAtIndex:[indexPath section]];
	}
	detailViewController.detailItem = [NSString stringWithFormat:@"%@ %@",theTitle, theYear];
}
Will display the title and the year, if a search is not being done.
Bob
 
Old February 21st, 2011, 02:57 PM
Friend of Wrox
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

For what it is worth, the following will display the title and date in the detailView when selected, whether search is on or off
Code:
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
	NSString *theTitle = [[[aTableView cellForRowAtIndexPath:indexPath] textLabel] text];
	NSString *theYear;

	for (NSString *yearKey in movieTitles) {
		for (NSString *aTitle in [movieTitles valueForKey:yearKey]) {
			if ([aTitle isEqualToString:theTitle]) {
				theYear = yearKey;
			}
		}
	}
	detailViewController.detailItem = [NSString stringWithFormat:@"%@ %@",theTitle, theYear];
}





Similar Threads
Thread Thread Starter Forum Replies Last Post
Author's code for chapter 8, TableView has issues rcutshaw BOOK: Beginning iOS 4 Application Development 1 January 15th, 2011 05:45 PM
chapter 3 question adamshire BOOK: Professional Ajax 2nd Edition ISBN: 978-0-470-10949-6 1 July 29th, 2010 06:09 PM
Chapter 5 Question 5 Will BOOK: Beginning Microsoft Visual C# 2008 ISBN: 978-0-470-19135-4 1 October 24th, 2009 09:18 AM
Question on Chapter 5 arholly BOOK: Expert Access 2007 Programming ISBN 978-0-470-17402-9 1 September 2nd, 2008 04:07 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.