Seven steps to segue from a Label or UIView: Move between View Controllers in Xcode storyboards (iOS 5 onwards)
In simplistic terms a segue is like an app's internal hyperlink system that enables movement between View Controllers, and here's seven simple steps on how you create them from scratch.
(1) First we need to create our SimpleSegue.xcodeproj file, a straightforward single view application will be fine.
(2) Next we need to navigate to the MainStoryboard.storyboard file and drag a label onto our View Controller and format it as required using the inspector (make sure also to check user interaction enabled)
(3) We then need to drag and drop onto this label a Tap Gesture Recognizer (if we had used a Round Rect Button this wouldn't have been necessary, but I wanted to demonstrate that buttons aren't the only way to segue)
(4) The next step is to embed this View Controller in a Navigation Controller using the Editor->Embed In option from the top menu bar
(5) We then need the new View Controller that we are going to move to, so zoom out and drag one of those onto your storyboard
(6) Finally we Ctrl + click + drag from our Tap Gesture Recognizer to the new View Controller and select Push from the pop up menu (you can try the other options later!)
(7) All the work is done, just run the program to check. When you click on the label you will be taken to a new screen with a back button. Click the back button and you will be taken back – nothing is required for this button to function.
(1) First we need to create our SimpleSegue.xcodeproj file, a straightforward single view application will be fine.
(2) Next we need to navigate to the MainStoryboard.storyboard file and drag a label onto our View Controller and format it as required using the inspector (make sure also to check user interaction enabled)
(3) We then need to drag and drop onto this label a Tap Gesture Recognizer (if we had used a Round Rect Button this wouldn't have been necessary, but I wanted to demonstrate that buttons aren't the only way to segue)
(4) The next step is to embed this View Controller in a Navigation Controller using the Editor->Embed In option from the top menu bar
(5) We then need the new View Controller that we are going to move to, so zoom out and drag one of those onto your storyboard
(6) Finally we Ctrl + click + drag from our Tap Gesture Recognizer to the new View Controller and select Push from the pop up menu (you can try the other options later!)
(7) All the work is done, just run the program to check. When you click on the label you will be taken to a new screen with a back button. Click the back button and you will be taken back – nothing is required for this button to function.
Comments
Post a Comment