2016-09-08 20 views
0

で時々動作します。 しかし、segue.destinationViewControllerは存在しません。 segue.destinationのみ存在します。Xcodeのセグエは、私は次のControllerViewに値を渡すためにしようとしているが、私はこのエラーを取得していますテーブルビュー

ControllerView 1:

class TechniqueListViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { 


var activeRow = 0 



let cellContent = ["Stance", "Move Forward", "Move Backward", "Move Right", "Move Left", "Jab", "Cross", "Hook", "Uppercut", "Body Jab", "Body Cross", "Body Hook", "Body Uppercut", "Leg Kick", "Body Kick", "Switching Stances", "Switch Leg Kick", "Switch Body Kick", "Push Kick", "Switch Push Kick", "Front Push Kick", "Switch Front Push Kick", "Spinning Back Kick", "Knee", "Switch Knee", "Elbow", "Tornado Kick"] 



public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int{ 
    //gets # of rows 


    return cellContent.count 
} 

public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell{ 
//defines content of each cell 

    let cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "TechniqueCell") 
    cell.textLabel?.text = cellContent[indexPath.row] 

    return cell 

} 

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 


    activeRow = indexPath.row 
    performSegue(withIdentifier: "IndividualTechniqueSe", sender:IndividualTechniqueController.self)  

} 

override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 
    if segue.identifier == "IndividualTechniqueSe"{ 

     let TechniqueIntent = segue.destination as! IndividualTechniqueController 
     TechniqueIntent.activeRow2 = activeRow 
} 


func viewDidLoad() { 
    super.viewDidLoad() 

    // Do any additional setup after loading the view. 
} 

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


/* 
// MARK: - Navigation 

// In a storyboard-based application, you will often want to do a little preparation before navigation 
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 
    // Get the new view controller using segue.destinationViewController. 
    // Pass the selected object to the new view controller. 
} 
*/ 

} 

}

ControllerView 2:

import UIKit 

class IndividualTechniqueController: UIViewController { 

var activeRow2 = 0 

override func viewDidLoad() { 
    super.viewDidLoad() 


    // Do any additional setup after loading the view. 
} 


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


/* 
// MARK: - Navigation 

// In a storyboard-based application, you will often want to do a little preparation before navigation 
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 
    // Get the new view controller using segue.destinationViewController. 
    // Pass the selected object to the new view controller. 
} 
*/ 

}

私はアプリケーションを構築し、行をタップするたびに、それだけに行きます希望のControllerView時間の10%。私は何か悪いことをしましたか?

+0

'//MARK: - Navigation'はエラーではありません。 –

+0

なぜ 'activerow'を使うのですか? 'tableView'のIBOutletはどこですか? 'destination view controller'でクリックされたインデックス番号を捕まえる必要がありますか? –

答えて

1

ControllerView 1:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 


      activeRow = indexPath.row 
      self.performSegueWithIdentifier("IndividualTechniqueSe", sender:nil)  

    } 

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

      if segue.identifier == "IndividualTechniqueSe"{ 

      let TechniqueIntent = segue.destinationViewController as! IndividualTechniqueController 
      TechniqueIntent.activeRow2 = activeRow 
      } 
    } 
関連する問題