Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Mobile Development > BOOK: Professional iPhone and iPad Database Application Programming
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional iPhone and iPad Database Application Programming
This is the forum to discuss the Wrox book Professional iPhone and iPad Database Application Programming by Patrick Alessi; ISBN: 978-0-470-63617-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional iPhone and iPad Database Application Programming 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 December 19th, 2011, 05:40 PM
Registered User
Points: 18, Level: 1
Points: 18, Level: 1 Points: 18, Level: 1 Points: 18, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Posts: 4
Thanks: 0
Thanked 1 Time in 1 Post
Default Chapter 3 - Image ProductDetailViewController

How can you load the item image in the ProductDetailViewController?
Thanks
Reply With Quote
The Following User Says Thank You to nickpsaris For This Useful Post:
Jule (April 2nd, 2012)
  #2 (permalink)  
Old December 22nd, 2011, 09:38 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

Assuming I understand your question right, you want the image that is on the left in the tableCell of the rootViewController to also appear in the ProductDetailView. Two options that are available are:
1. add a UIImageView to the ProductDetailViewController.xib and as an IBOutlet in the ProductDetailViewController.h. (additions are bold)
@interface ProductDetailViewController : UIViewController {


IBOutlet UILabel* nameLabel;
IBOutlet UILabel* manufacturerLabel;
IBOutlet UILabel* detailsLabel;
IBOutlet UILabel* priceLabel;
IBOutlet UILabel* quantityLabel;
IBOutlet UILabel* countryLabel;
IBOutlet UIImageView *productImage;


}
Make the connection. In the ProductDetailViewController.m add the following (additions are bold)

-(void) setLabelsForProduct: (Product*) theProduct
{
// Set the text of the labels to the values passed in the Product object
[nameLabel setText:theProduct.name];
[manufacturerLabel setText:theProduct.manufacturer];
[detailsLabel setText:theProduct.details];
[priceLabel setText:[NSString stringWithFormat:@"%.2f",theProduct.price]];
[quantityLabel setText:[NSString stringWithFormat:@"%d",theProduct.quantity]];
[countryLabel setText:theProduct.countryOfOrigin];
NSString *filePath = [[NSBundle mainBundle] pathForResource:theProduct.image ofType:@"png"];
UIImage *image = [UIImage imageWithContentsOfFile:filePath];
productImage.image = image;

}
and option 2 would entail adding the UIImageView in code as a subview of the ProductDetailController.view rather than in the .xib and as an IBOutlet

2. In the ProductDetailViewController.m add the following (additions are bold)


-(void) setLabelsForProduct: (Product*) theProduct
{
// Set the text of the labels to the values passed in the Product object
[nameLabel setText:theProduct.name];
[manufacturerLabel setText:theProduct.manufacturer];
[detailsLabel setText:theProduct.details];
[priceLabel setText:[NSString stringWithFormat:@"%.2f",theProduct.price]];
[quantityLabel setText:[NSString stringWithFormat:@"%d",theProduct.quantity]];
[countryLabel setText:theProduct.countryOfOrigin];
UIImageView *prodImage = [[UIImageView alloc] initWithFrame:CGRectMake(200, 20, 100, 100)];
[self.view addSubview:prodImage];
NSString *filePath = [[NSBundle mainBundle] pathForResource:theProduct.image ofType:@"png"];
UIImage *image = [UIImage imageWithContentsOfFile:filePath];
prodImage.image = image;
[prodImage release];

}

Since the original project is "pre ARC" the retain/release pattern is used.
Hope this helps.

Bob
Reply With Quote
The Following User Says Thank You to thepianoguy For This Useful Post:
Jule (April 2nd, 2012)
  #3 (permalink)  
Old December 27th, 2011, 04:56 PM
Registered User
Points: 18, Level: 1
Points: 18, Level: 1 Points: 18, Level: 1 Points: 18, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Posts: 4
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thank you very much it work!!!!!!
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
Chapter 8 - URL for image weimenglee BOOK: Beginning Android Application Development 0 May 5th, 2011 09:27 PM
CHAPTER 7 - UPDATE an Image dutraveller BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 4 March 20th, 2008 12:27 PM
Chapter 7 - Image Problem SoftMind BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 4 June 19th, 2006 04:30 PM
Chapter 5-Image Mapping Help! maxcain Dreamweaver (all versions) 3 March 16th, 2004 08:00 AM



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


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