I have a problem with image transferring that I don't understand. I want to display an UIImage of an UIImageView on another controller if the user executes a "Long Press Gesture". The other controller will be shown but the image I transfer won't be displayed.
The button is connected with a third controller over a modal storyboard segue. There the user is able to capture the image. On "ok" the controller switches back to the first one and the captured image will be displayed within an UIImageView. No problems until there. To achieve the long press gesture guides to an other controller I dropped the gesture to the storyboard and connected the button to it. If the user executes the gesture following function will be executed
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([[segue identifier] isEqualToString:@"toPreview"]){
PreviewViewController *pvc = (PreviewViewController *)[segue destinationViewController];
[pvc setImage:signatureView.image];
}
}
The signatureView is an UIImageView that displays the user captured image (in this case a signature). the "setImage:(UIImage*)" function is one of many possibilities I tried.
Here is the code of the controller that should display the image
@interface PreviewViewController : UIViewController
@property(nonatomic, retain) IBOutlet UIImage *previewImage;
@property (weak, nonatomic) IBOutlet UIImageView *previewImageView;
- (void) setImage:(UIImage *)image;
@end
@implementation PreviewViewController
@synthesize previewImage;
@synthesize previewImageView;
- (void) setImage:(UIImage *)image {
previewImage = image;
previewImageView.image = previewImage;
[previewImageView setNeedsDisplay];
}
...
As I already said I tried many possibilities but nothing displayed the passed UIImage within the previewImageView. I tried to write the image of the previewImageView directly from the first controller, I passed the complete UIImageView of the first controller, ...
I don't understand whats my fault. Can anybody help me? I'm using XCode 4.2 and iOS 5 SDK
Ben