2016-05-01 10 views
-3

私は配列の内容を示すtableViewを持っています。Swiftで新しいテーブルビューを追加

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { //currnet table information. 
    let cell = UITableViewCell() 

    if chartTitle[indexPath.row] == "Name" { 
     cell.textLabel?.text = chartTitle[indexPath.row] 
    } 
    else if ... { 
     ...... 
    }  

    return cell 
} 
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 
    return chartTitle.count 
} 

は今、私は別の配列の内容を示して新しいのtableViewを追加したいが、両方のtableViewは、同じクラスのUITableViewを持っているので、私は実現することは困難です。

別の配列に依存して新しいtableViewを追加してその行を管理するにはどうすればよいですか?

ありがとうございます。

答えて

0

あなたはあなたの関数cellForRowAtIndexPathでテストすることができますし、他の同様numberOfSectionsInTableViewnumberOfRowsInSectionなど:

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 

    if tableView == self.firstTableView { 
      // do something 
    } else if tableView == self.secondTableView { 
      // do something else 

} 
関連する問題