I'm newbie in swift iOS
. In my storyboard, I've created some dynamic fields from viewController
. Have created a button from object library.
Now I need to open an new empty screen after clicking this button. In the new screen, there'll be some input fields. I'll create those through programming or object library.
But I'm unable to open the empty screen.
@IBAction func SaveTgw(sender: AnyObject) {
print("test=====")
}
I need to include the screen opening code within SaveTgw
. Any help or any descriptive tutorial link would be appreciated....
1-From Utilities open identity inspector in storyboard ID enter id "MySecondSecreen"
2-In your method add the following code :
@IBAction func SaveTgw(sender: AnyObject) {
let storyboard = UIStoryboard(name: "Main", bundle: nil);
let vc = storyboard.instantiateViewControllerWithIdentifier("MySecondSecreen") as! UIViewController; // MySecondSecreen the storyboard ID
self.presentViewController(vc, animated: true, completion: nil);
}
Create a SecondViewController
in Main.storyboard like this -
On Scan
button click , do following code
@IBAction func scanAction(sender: AnyObject) {
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let secondViewController = storyBoard.instantiateViewControllerWithIdentifier("SecondViewController") as SecondViewController
self.presentViewController(secondViewController, animated:true, completion:nil)
}
There are many answers available, just do a search -
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With