I am newbie in iOS development and currently stuck on creating back button. I already placed popViewControllerAnimated method on tapping button, also I test it on debugging mode and back button method is calling but popViewControllerAnimated is not working.
Here is the code.
- (void)viewDidLoad
{
[super viewDidLoad];
UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake((self.view.frame.size.height-100), 30, 80, 20)];
[backButton setTitle:@"Back" forState:UIControlStateNormal];
[backButton addTarget:self action:@selector(BackButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:backButton];
//some piece of code...
}//end of viewDidLoad method
-(void)BackButtonClicked: (id)sender{
[self.navigationController popViewControllerAnimated:YES];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"testing" message:@"some message" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:@"NO", nil];
[alert show];
}
On tapping back button this alert is showing but screen is not going back.
Any help regarding this issue will be highly appreciable.
I called this viewController by writing this code in my previous viewController
PlaceTranslatedDetailsViewController *secondViewController =
[self.storyboard instantiateViewControllerWithIdentifier:@"placeTranslatedDetail"];
[self presentViewController:secondViewController animated:YES completion:NULL];
However, this viewController and previous viewController were designed programmatically
use this code:
[self dismissViewControllerAnimated:YES completion:NULL]