I am a beginner in iOS programming and I want to implement the functionality of going back to home view.
I have use this code:
-(IBAction)onclickhome:(id)sender
{
[self.navigationController popViewControllerAnimated:YES];
}
I have used navigationController in home button click event but it is not jump to home screen.
Do you have any suggestion and source code which applies to my code?
I'm not sure I understand your question.
What do you mean with
?
If you want to pop to the root controller you can use
popToRootViewControllerAnimated
.From Apple doc of
UINavigationController
If you have set up a
UINavigationController
and its root controller is called A, then if you navigate from A to B and then from B to C you have two possibilities to come back to a previous controller (you can have others but I list the main ones):popViewControllerAnimated
popToRootViewControllerAnimated
The best way to navigate back and forth views is by pushing and popping views from navigation view controller stack.
To go one view back, use below code. This will ensure that the smooth transition between views are retained.
To go two views back, do as below
If you aren't going back to your expected view, execute below code before popping any of the views...
You should see an array like the below one, which will help you in verifying the stack is maintained as expected.
I use
since others answers didn't worked in Xcode 8.0