Post
by grovecat » Mon Apr 23, 2012 1:47 pm
The text has be automatically centered, both horizontally and vertically. I can do that with a text field but not with a button.
I did belatedly realise that I can simply treat the buttons as image areas and manipulate the layers as I am doing already.
This saga is becoming a bit convoluted, so I'll try to outline the story so far.
The user of my app can load photos into several different square image areas on different cards. They have to be square for reasons I don't need to bother with here. Up until recently those have all been pictures of album covers downloaded from the web and put into the iPad camera roll. They are always square, so I set the iPhonePickPhoto command to ask for a square image such as with iPhonePickPhoto library, 300,300. The app puts the last image into a global variable and from there puts it into the various image areas. As the photos are themselves square there has been no problem. And I should mention that the images are part of the user data and I save them as jpg files in the caches folder under session names. So far so good.
Now the user wants to access photos that are in standard 4 x 3 format from either the library or the camera, but still placed into the square image areas (that is, cropped). When this happens, although the iPickPhoto command asks for a square image, what is actually returned is one in 4 x 3 format. For example, the above command is set to 300, 300 but it will return an image that is 400 x 300. When that is put into a square image area it is squashed horizontally and thus distorted.
I therefore had a look at the crop command as that seemed to offer a solution. However, a cropped image cannot be "put" into another image area as I mentioned in the topic "Can't access a cropped image". So I was not able to put it into the required image areas in the app. Mark suggested that I use the set imageData command, which at first seemed to be the answer. However, it does not work when the two image areas are different sizes as I mentioned in the topic "Cropping and Image Data Woes".
In a response to that post, Klaus recommended using the snapshot command instead. Unfortunately the same problem arose with that in trying to place the image into other image areas, leading to the current thread. I have tried all the ideas here and have essentially always come up against the same problem -- I can't get a cropped image into other image areas.
The button id technique suggested by Jacque looks promising. However, I am a bit concerned by the statement ".. the icons are all set immediately after import. They will persist until you either delete the image or change the icon later." As the app is placing multiple images, what happens to first one when the next one becomes the new last image? Will each successive image cause the previous one to be deleted? If not then I can do what is needed with the button id system.
But after all this the main question remains unanswered: Is it possible to somehow put a cropped image (obtained by any method that works) into other image areas? None of the things I have tried have worked so either I am missing something so fundamental that everyone else takes it for granted, or it really is a bit hard.
My sincere thanks to all the patient people who have taken the trouble to advise me on this.
Cheers
Don