Ho il seguente codice per visualizzare due tabelle popolate da due array diversi in un'unica vista:Due tavoli su una vista in rapida
@IBOutlet var RFTable: UITableView
func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
}
override func viewDidLoad() {
super.viewDidLoad()
self.RFTable.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")
}
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
return self.RFArray.count;
}
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
var cell:UITableViewCell = self.RFTable.dequeueReusableCellWithIdentifier("cell") as UITableViewCell
cell.textLabel.text = String(self.RFArray[indexPath.row])
return cell
}
@IBOutlet var IMProdTable: UITableView
func tableView2(IMProdTable: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
}
override func viewDidLoad() {
super.viewDidLoad()
self.IMProdTable.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell2")
}
func tableView2(IMProdTable: UITableView!, numberOfRowsInSection section: Int) -> Int {
return self.IMProdArray.count;
}
func tableView2(IMProdTable: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
var cell2:UITableViewCell = self.IMProdTable.dequeueReusableCellWithIdentifier("cell2") as UITableViewCell
cell2.textLabel.text = String(self.IMProdArray[indexPath.row])
return cell2
}
ho ottenuto il primo tavolo di lavoro, e poi copiato e incollato il testo, sostituendo i nomi degli array e i nomi delle tabelle e collegando il delegato e l'origine dati. Tuttavia Xcode visualizza la "redeclaration non valida di viewdidload" sul secondo codice (incollato). Se lo sostituisco con 'fund loadView() {' invece di viewdidload i build dell'app. Tuttavia, quando eseguo il test, entrambe le tabelle visualizzano esattamente gli stessi dati dei dati in "RFArray". Sono MOLTO nuovo nella programmazione e non riesco a vedere cosa ho fatto, per favore aiuto.
Grazie mille, ha perfettamente senso, grazie per la spiegazione. Ha funzionato la prima volta – samp17