Reputation: 39
I am practicing IOS app using swift.
I have created three view controllers Default, Login view, and Register Page. 1)Default view is embedded with a Navigation controller. 2)Default view is connected through a segue(Present Modally) 3)In Login view, SignUp button is connected through a segue(present Modally) to Register view.
Expected: I should see default view and then Login view should load.
Problem: I can see only default view. But I am unable to see Login view.
Attached screenshot is my UI. Please zoom for better view.
Hope any one will help me. Thank you in advance.
Upvotes: 0
Views: 74
Reputation: 101
Your Storyboard seems to be fine.
There are two different ways to perform a wind segue:
Direct segue
1.1 Just drop an UIButton into your first View Controller.
1.2 Then pressing Ctrl, select the button and drag it into the second View Controller (Login View Controller). A blue arrow will appear, drag and drop it into the next view controller.
1.3 Done! You can run your app and click on the added button, it will send you to the next view controller.
Programmatically segue:
2.1 For each one of your segues you need to provide an identifier. For this, you need to go to your storyboard, select each segue and give a name on the inspector.
2.2 Create a ViewController Cocoa Touch Class file for each View Controller in your Storyboard ( File > New > File... > Cocoa Touch Class).
2.3 Once done, it will show you the recently ViewController file instead of the storyboard. Go again to your Storyboard Select the second View Controller (lets call it OtherViewController), and then go to the “Identity Inspector” in the Utility Pane. It’s the icon that looks like a card with a picture in the top left corner and some writing everywhere else (it’s selected in blue in the screenshot below). In there, set the “Class” part of the “Custom Class” section to our new OtherViewController. If it is a compatible subclass (in this case of UIViewController), it will accept it. It will also probably autocomplete once you start typing a compatible class.
2.4 Next, you need to generate an action to perform the segue and go from one View Controller to another. Additionally, you can send a value to the next view controller (eg. numberToDisplay). For this you will need to add this code:
Code:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "SegueCustomIdentifier"
{
if let destinationVC = segue.destinationViewController as? OtherViewController {
destinationVC.numberToDisplay = counter
}
}
}
2.5 To perform this segue, you will need to add the next code into your first View Controller and attach it to a simple action, for example: a button pressed event.
self.performSegueWithIdentifier("HAIDetails", sender: self)
For more details please visit: tutorial
Upvotes: 1