i have two view controllers in iphone application.
1.) FirstVC
2.) SecondVC
In my FirstVC i have one button. By tapping on that button i opened SecondVC in presentModalViewController
. look bellow code.
- (IBAction)buttonClicked:(id)sender
{
SecondVC *secondVC = [SecondVC alloc] initWithNibName:@"SecondVC" bundle:nil];
[self.navigationController presentModalViewController:secondVC animated:YES];
}
now moved to SecondVC. On SecondVC i have create navigation bar as well as "cancel" button as a leftBarButtonItem. i set a button clicked event on cancel button. in that method i want to dismiss SecondVC. bellow method is in SecondVC. look bellow code.
- (void)cancelButtonClicked
{
[self dismissModalViewControllerAnimated:YES];
}
This code dosen't work. i can't dismiss SecondVC by this code. Please suggest another tricks.
Change the button code to this..
- (IBAction)buttonClicked:(id)sender
{
SecondVC *secondVC = [SecondVC alloc] initWithNibName:@"SecondVC" bundle:nil];
[self presentViewController:secondVC animated:YES completion:NULL];
}
on cancelButtonClick
-(void)cancelButtonClicked {
[self.presentingViewController dismissViewControllerAnimated:YES completion:NULL];
}