2016-06-26 2 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에서 행을 탭하면이 함수가 호출되기 때문에 –

관련 문제