Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prepare for segue not working with swift

I using a tableView inside a viewController. I am trying to send data to a detailViewController. But for some reason i can't push to the detail view. I am not getting any errors. Its just not working.

Here is my code for the segue:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject) {

        if (segue.identifier == "test") {

            let detailViewController: DetailViewController = segue.destinationViewController as DetailViewController
            //println(index)

            detailViewController.fromPreviousView = index


      //
    }
like image 311
user1951876 Avatar asked Dec 05 '25 15:12

user1951876


1 Answers

You registering tableView cell programatically , So it will create different cell not the one in the storyboard so there is no segue.

Solution is delete this line of code self.tableViewOutlet.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell") and give cell identifier to the cell in story board to "cell". It will work.

like image 51
Yatheesha Avatar answered Dec 07 '25 03:12

Yatheesha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!