p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning iOS 4 Application Development (http://p2p.wrox.com/forumdisplay.php?f=599)
-   -   Chapter 13: rect undefined (http://p2p.wrox.com/showthread.php?t=87370)

Em_Ga April 25th, 2012 03:47 AM

Chapter 13: rect undefined
 
In .m Lines
"//---get the cropping rectangle applied to the image---
CGRect rect = [[info valueForKey:UIImagePickerControllerCropRect] CGRectValue];"

I am getting an undefined for "rect" above. When I downloaded and ran the sample code I received the same error message.

Also, how do I add pics to the simulator so the simulator can display actual pictures when this runs?

Thanks for the help.

Em_Ga April 25th, 2012 10:38 AM

More information ...
 
rect in line "CGRect rect = [[info valueForKey:UIImagePickerControllerCropRect] CGRectValue];"
is found on page 330, Under Accessing the PhotoLibrary in step #8. and located in the PhotoLibraryViewController.m file.

Since the same undefined error occurs with the downloaded code from wrox, I am hoping someone has come across this and can help.

thepianoguy April 25th, 2012 11:18 AM

I don't have the book but working form the downloaded codeā€¦

A simple way to add photos to the PhotoLibrary is to run Safari in the simulator then drop an image into the browser window. Click and hold on the image and you will be given the option to save the image.

You will need to change the btnClicked: method to use either

imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;

or

imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

the line the author has commented out. Since you are not using the camera you should comment out the lines following the //-invoke the camera comment through the // -show the ImagePicker comment. These lines will cause a crash on the simulator since no camera exists.

The CGRect that is giving an "unused" (you said "undefined", I am not getting that) warning is irrelevant as the program is written, since this rect can only exist if you use the camera and crop the photo. The warning can be ignored, and since without using the camera that branch of the if-else will never be reached anyway.




Bob

Em_Ga April 25th, 2012 12:21 PM

Working better ...
 
Thanks!. I can now list the photo albums and select a picture with the sample code. But I can not do anything with the picture I selected or even move to the next picture unless I reload all the pics. Did I miss something or need another change?

thepianoguy April 25th, 2012 01:12 PM

What are you expecting to be able to do with the image? The project doesn't appear to go beyond accessing and displaying the image. The imagePickerController is modal so it hides when the image is shown, if it did not then it would cover the display of the selected image. So the choices (in the imagePicker)and selected image can not be visible simultaneously. That is why the imagePicker must present, then hide after the selection.

Clarify what you think is missing from functionality.

Bob

Em_Ga April 25th, 2012 02:32 PM

My misunderstanding. Sorry. I thought you could flip through pictures using this method. I'll need a different method it appears. Thanks for the help.


All times are GMT -4. The time now is 06:09 PM.

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