I am new in ios development and I want to add back button in my app.
For this I write code in -(view)didLoad
:
UIButton *btnbarBack = [UIButton buttonWithType:UIButtonTypeCustom];
btnbarBack.frame = CGRectMake(0, 0, 30, 22);
[btnbarBack setImage:[UIImage imageNamed:@"arrow_left.png"] forState:UIControlStateNormal];
[btnbarBack addTarget:self action:@selector(OnClick_btnBack:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *btnbarBack_1 = [[UIBarButtonItem alloc] initWithCustomView:btnbarBack];
self.navigationItem.rightBarButtonItem = btnbarBack_1;
and I use popViewController to go back Clickevent code is :
-(IBAction)OnClick_btnBack:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}
But when I click on button event fires but no change appear!
I already tried:
-[self.navigationController pushViewController:self.navigationController.parentViewController animated:YES];
-[self.parentViewController.navigationController popToRootViewControllerAnimated:YES];
-[self dismissViewControllerAnimated:YES completion:nil];
But these 3 also not working. Is there any other option to solve this problem.