Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Mobile Development > BOOK: Beginning iPad Application Development
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
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?
Reply With Quote
  #2 (permalink)  
Old February 20th, 2011, 12:44 PM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
  #3 (permalink)  
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.
Reply With Quote
  #4 (permalink)  
Old February 21st, 2011, 12:53 AM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
  #5 (permalink)  
Old February 21st, 2011, 02:57 PM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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];
}
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 07:09 PM
Chapter 5 Question 5 Will BOOK: Beginning Microsoft Visual C# 2008 ISBN: 978-0-470-19135-4 1 October 24th, 2009 10:18 AM
Question on Chapter 5 arholly BOOK: Expert Access 2007 Programming ISBN 978-0-470-17402-9 1 September 2nd, 2008 05:07 PM



All times are GMT -4. The time now is 07:04 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.