views:

24

answers:

1

Hello,

i am using a UINavigationController in my application. in the first view i am displaying some information and have a button for loading an picture from the camera. this works fine so far. when the picture was loaded, i want to display the picture in a UIImageView within a second view. Therefore i am using the following code.

MyAppDelegate *delegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
CorrectedImageController *imageController = [[CorrectedImageController alloc] initWithNibName:@"CorrectedImageView" bundle:nil];
self.correctedImageViewController = imageController;
[imageController release];      
[delegate.navController pushViewController:imageController animated:YES];

The second view is loaded and the picture is shown. But i get an EXC_BAD_ACCESS message in the Debugger Console and my Application blocks the UI.

In the second view the picture is loaded as follows:

- (void)viewDidLoad {
  MyAppDelegate *delegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
  [imageView setImage:delegate.correctedImage];
  [super viewDidLoad];
}

Can anybody tell me, what i did wrong ? My nib file looks:

-File's Owner (Corrected Image Controller)
-First Responder (UIResponder)
-View (UIView)
--ImageView (UIImageView)

The File's owner view property is connected to the view. And the imageView property is connected to the ImageView.

Can anybody tell me, what i did wrong ?

BR, Martin

A: 

I believe this is because you are calling release on the imageController (line 5) and then trying the pushModalView the object you just released (line 6). If your self.correctedImageViewController is retaining the imageController, you could push the self.correctedImageViewController or release the imageController after the push.

Eric