2017-05-01 3 views
0

私はiPhoneのメモアプリケーションのようにtableViewを使用しています。 メモ(cells)を追加/削除できます。tableView内の特定のviewControllerを開く

メモを削除すると少し問題に直面しています。ここで

は私のコードです:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { tableView.deselectRow(at: indexPath, animated: true) 



    switch (indexPath as NSIndexPath).row { 
    case 0: 




     let Liste1 = self.storyboard!.instantiateViewController(withIdentifier: "liste1") as UIViewController 
     self.present(Liste1, animated: false, completion: nil) 

    case 1: 
     let Liste2 = self.storyboard!.instantiateViewController(withIdentifier: "liste2") as UIViewController 
     self.present(Liste2, animated: false, completion: nil) 

    case 2: 
     let Liste3 = self.storyboard!.instantiateViewController(withIdentifier: "liste3") as UIViewController 
     self.present(Liste3, animated: false, completion: nil) 



    default: 
     break 

    } 

あなたが見ることができるように、各indexPath.rowがカウントViewControllerを開くことができます。 3枚のメモがあり、2枚目を削除すると、3枚目は2番目のviewControllerが開きます。あなたが理解していない場合私に教えてください。 私は問題を知っている、私はいくつかの解決策が特定のviewControllerを開く場合はわからない。事前に

Iは、細胞が、ないindexPathによってviewControllerにリンクされたい。..

ありがとう!

答えて

2

ここの実装は間違っています。どのようにしなければならないのは、ユーザがセルを選択するたびにViewController(DetailsViewControllerという名前)をプッシュすることです。テキストに関連するテキスト/メモのみが変更されます。正しい音符は、すべての音符の配列(選択されたセルのindexPath.rowであるインデックスを持つ)から取得し、それを提示しながらDetailsViewControllerに渡す必要があります。

メモの削除: ユーザーがメモを削除すると、このメモのすべての配列からnotを削除するだけです。

+0

本当にありがとうございます!それは私が思う単純な見解の質問だった.. – Matt

+0

あなたはようこそ... :) – dRAGONAIR

関連する問題