新しいviewControllerにデータを送信しようとすると問題が発生します。 この行は、私は新しいのViewControllerへのパスを取得するので、整数といくつかの問題になりそうです整数をSegueに渡す
destination1.path = path
実行されます。
私はこのエラーメッセージを得る:
2017年5月26日20:37:14.442509 + 0200サブスクリプション[1224:301622]のUIView:0x105d294f0。フレーム=(0 0; 414 736);自動サイズ調整= W + H; layer = CALayer:0x17403f360 >>のウィンドウがSubscription.ViewController2:0x105d3fcb0>のビューのウィンドウと等しくない!
// method to run when table view cell is tapped
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print("You tapped cell number \(indexPath.row).")
let index = indexPath.row
performSegue(withIdentifier: "EditSegue1", sender: index)
}
@IBAction func backButton(_ sender: Any) {
self.dismiss(animated: true, completion: nil)
}
// Prepare for next view.
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let destination1 = segue.destination as? ViewController2 {
destination1.path = path
if let index = sender as? Int {
destination1.index = index
}
}
}
私の第二のViewController。
var path = ""
var index = 0
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
print(path)
print(index)
}
送信者は決して整数ではありません。私はあなたが望むものは 'センダー。 Int' –
私は、このコードはクラッシュしてはならないので、Int値にエラーがないと思います。私はそれはあなたと何かだと思うUI –
あなたは 'prepareForSegue:sender:'を手動で準備する必要はありません。これは、ストーリーボードセグが開始されると自動的に呼び出されます –