2016-06-26 6 views
1

私は問題を抱えています。テーブルセルSegueWayが動作しない - SWIFT

私がセルをクリックすると、別のページに行きたい、segueWay接続とその他すべてを作成しました。

しかし、これをシミュレータで実行しても機能しない場合は、何も起こらないセルをクリックしてください。

enter image description here

のtableViewコード:

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) 
      } 
    } 


} 

答えて

2

私は、次のコード行が欠落して、問題を発見しました。

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

     performSegueWithIdentifier("testing", sender: self) 
    } 

上記の機能を追加すると、すべてうまく機能します。

+0

これは、tableviewの行をタップすると呼び出される関数 –

関連する問題