If you're into JavaFX, see how this Apple-oriented post compares with this video.
The following video shows an iPod running the app on iOS 9. Swiping down on the Main Content Screen brings up the Additional Content Screen. Swiping up on the Additional Content Screen returns the Main Content Screen.
Two UIViewControllers are added to an Xcode 7 project (one was created by Xcode based on the Single View Application project type). Each UIViewControllers has a UILabel centered in the UIView and the background of Main Content Here is set to blue.
Single View Application with Two UIViewControllers |
The first step will add a down Swipe Gesture Recognizer to the Main Content VC. From the toolkit in the lower right hand of the screen, drag Swipe Gesture Recognizer to Main Content VC. This will add a fourth icon to the top of the VC (a blueish white box to the left of the exit button).
Drag Swipe Gesture Recognizer to Main Content VC |
Control + drag from the newly-added Swipe Gesture Recognizer to the Additional Content VC. Define this as a Show segue.
At this point, the application will navigate from the Main Content VC to the Additional Content VC with a down swipe (but won't return yet).
Step 2 - Add Code
In the UIViewController subclass supporting Main Content VC (is "ViewController.swift" if you're using the XCode-generated VC), add the following code. The actual name of the method is not important, only that it's marked as an @IBAction and takes a single UIStoryboardSegue argument.
Note that this code belongs in the unwind target which is the Main Content VC. Even though we'll be hooking this up in the next step to Additional Content VC's Exit button, this code does not go into the UIViewController Swift file of Additional Content VC.
@IBAction func unwindToMainContent(segue:UIStoryboardSegue) {
}
Similar to what was done in Step 1, add a Swipe Gesture Recognizer to Additional Content VC. In the properties panel, set this Swipe direction to "Up".
At the top of the Additional Content VC, Control + Drag from the newly-added Swipe Gesture Recognizer icon to the Exit icon. The method name added in Step 2 will appear ("unwindToMainContent" if you're using my name). Select this.
Wiring a Swipe Gesture Recognizer to an Unwind Segue |
No comments:
Post a Comment