Reputation: 37
I'm trying to send some values from one viewcontroller to another. (all embedded in NavigationController). I could make segue with normals viewcontrollers so in general I understand a segue idea. I've to do that in two different ways and got two different problems.
First way, segue does right but "two times". I mean after segue (which I want) there is another segue to same controller but without navigation controller and without data I would send. The "back" button on last viewcontroller is returning to AlmostViewController.
Here's code:
Second way, Nothing happened,
ErorCould not cast value of type 'RevisionApp.AlmostViewController' (0x1055d58c0) to 'UINavigationController' (0x107669f18).
Upvotes: 2
Views: 2166
Reputation: 79
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let nextViewController = storyBoard.instantiateViewControllerWithIdentifier("ViewController2") as NextViewController self.presentViewController(nextViewController, animated:true, completion:nil)
Upvotes: 0
Reputation: 8066
Problem is line number 18. You are trying to cast AlmostViewController
to a UINavigationController
. Directly access like this,
let detailController = segue.destination as! AlmostViewController
Upvotes: 0
Reputation: 1263
For the first Problem, When using embedded in navigation controller you have don't have to create action function when the button is tapped. Navigation controller does it for you. So things you need to do :
btnTapped
from the button using storyBoard.btnTapped
(You don't need it).Upvotes: 0