I have created 3 views.
1st view is home, 2nd is inventory and 3rd is overlay view.
Now from home screen using pushviewcontroller, i am navigating to the inventory view screen.
In inventory view i have one capture button. capture button will open camera on overlayview.
Now the issue is there is a button called back button in the overlayview, when i click on this button i want to navigate to the home screen, but for that i need to 1st dissmiss the camera. How is this possible?
Capture Button in Inventory View
-(IBAction) btnCapture:(id) sender
{
@try
{
[self showImagePicker:UIImagePickerControllerSourceTypeCamera];
}
@catch (NSException *exception)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Camera" message:@"Camera is not available " delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[alert release];
}
}
In OverlayView Back button Event:
-(IBAction)btnBack:(id)sender
{
app.navcntr=1;
[self.delegate didFinishWithCamera];
[self dismissModalViewControllerAnimated:YES];
}
and in Inventory View, viewWillAppear
-(void) viewWillAppear:(BOOL)animated
{
if(app.navcntr ==1)
{
[self.navigationController popToRootViewControllerAnimated:YES];
}
app.navcntr=0;
}
The issue is it is navigating to home screen but application get crashed.
How to solve it?
Thanks.

I think you are trying to dismiss your camera view twice. I mean
didFinishWithCameramethod will dismiss it. Remove the line[self dismissModalViewControllerAnimated:YES];EDITED
You should not perform animations when you are not on screen (“will appear”).
Write your code in
viewDidAppearlike