bruno
bruno

Reputation: 61

Table Cell SegueWay not working - SWIFT

I'm facing a problem when dealing with tables on swift.

When i click in a cell, i want to go to another page, i've created the segueWay connection and everything else.

But when running this in the simulator doesn't work, click on a cell an nothing goes on.

enter image description here

TableView Code:

import UIKit

class TableViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 2
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        var cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "LabelCell")

        cell.textLabel?.text="conteudo da linha"
        cell.detailTextLabel?.text = "Details"
        return cell
    }

   /* func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

        tableView.deselectRowAtIndexPath(indexPath, animated: false)
    }*/

     override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
            print("Hello")
            if (segue.identifier == "testing"){
                let vc = (segue.destinationViewController as! EditarController)
            }
    }


}

Upvotes: 1

Views: 438

Answers (1)

bruno
bruno

Reputation: 61

i've found the issue, i was missing the following code lines.

  func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

        performSegueWithIdentifier("testing", sender: self)
    }

If you add the function above everything works well.

Upvotes: 2

Related Questions