がViewController with a single tableViewの優れた書き込みアップにフォローアップして、カスタムセルを有する複数のUITableViewsをswift3、私は2別々の tableViewsと独立してそれぞれ1つに属するカスタムセルを有する者への質問を拡張したいと思います。xcode8が
現時点では、私は半加工のスケルトンを持っていますが、これを解決するためのよりエレガントで簡単ではない方法があると確信しています。
- のviewDidLoad()
vInfoTV.dataSource = self
vInfoTV.delegate = self
vInfoTV.tag = Int.min
vAppTV.dataSource = self
vAppTV.delegate = self
vAppTV.tag = Int.max
- numberOfRowsInSection機能
func tableView(_ tableView: UITableView, numberOfRowsInSection section:Int) -> Int {
if tableView.tag == Int.min {
return mydata.cats.count
} else {
return mydata.dogs.count
}
}
はそれが私がここで行うようにtableViewさんのタグを設定し、それらをスイッチオンすることが適切である後タグの値に基づいていますか? func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if tableView.tag == Int.min {
// Cat Table View
if indexPath.row == 0 {
let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "firstCustomCell")
//set the data here
return cell
}
else if indexPath.row == 1 {
let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "secondCustomCell")
//set the data here
return cell
}
else {
let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "thirdCustomCell")
//set the data here
return cell
}
} else {
// Dog Table View
if indexPath.row == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: "poodleCell", for: indexPath) as! NewApplicationViewCell
cell.typeL.text = Dogs[(indexPath as NSIndexPath).row].type
return cell
}
else {
let cell = tableView.dequeueReusableCell(withIdentifier: "mastifCell", for: indexPath) as! InitialDMVInspectionTableView
cell.typeL.text = Dogs[(indexPath as NSIndexPath).row].type
return cell
}
}
- で
- 細胞今は細胞(すなわちデータなし)を持っていないのtableViewを、隠すための最良の方法は何ですか?
これは正しい方法ですか?コメントはすべて歓迎します!
感謝!