I create one application that has 3 ViewController with names : (ViewController,ViewController2,ViewController3) in ViewController exist one button that is for checking file in document folder or download it.for example first to check file if file exist in document folder go to ViewController3 else go to ViewController2 and download it.
so ViewController2 is for download and has UILable & UIProgress for show download status.if file dont exist in this page downloaded and go to ViewController3.
so ViewController3 is for show file. (these pages connect together with push segue like my image in bottom)
when I go to any page and I click back button return pervious page right?? I when to click on button in first page and file dont exist and downloading in second page then finished download go to page 3.Now I want when to click on back button in page 3 go to page 1 no page 2!!!!
I to work in storyboard.
You can achieve this by intercepting the back button event in ViewController3 and using unwindSegues. Check out William Jockusch's reply to this question for how to intercept the back button event.
To use the unwind segues in this particular case you then need to:
1) In your ViewController1 create a method such as
2) In your storyboard zoom out, then ctrl-drag from your ViewController3 to the "Exit" green box on the left contained in your ViewController3 scene (along with the red box First Responder and all your controller view's subviews). A popup window will show, asking what IBAction you want to connect the unwind segue to, and you should be able to select the
unwindToThisViewController
action that you just created. This will create an unwind segue.3) Select from the scene box this unwind segue and give it an ID, such as "unwindToStart"
4) Finally, in your ViewController3 class, override the method
viewWillDisappear
as follows:This will intercept the back button event and unroll to your ViewController1, and you're good to go.
EDIT: As unwind segues are supported only on iOS 6 and later, if you need this functionality on earlier versions of iOS I think the only way is to manually remove the ViewController2 from the NavigationController stack in your ViewController3's viewDidLoad. Something like the following code should do: