Tôi có đoạn code sau để hiển thị hai bảng cư từ hai mảng khác nhau trong một quan điểm:Hai bảng trên một cái nhìn trong nhanh chóng
@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
}
tôi đã làm việc bảng đầu tiên, và sau đó sao chép và dán văn bản, thay thế tên mảng và tên bảng, và đã kết nối đại biểu và nguồn dữ liệu. Tuy nhiên Xcode hiển thị 'redeclaration không hợp lệ của viewdidload' trên mã thứ hai (được dán). Nếu tôi thay thế điều này thành 'loadView của quỹ() {' thay vì viewdidload ứng dụng được tạo. Khi tôi thử nghiệm nó mặc dù, cả hai bảng xem chính xác cùng một dữ liệu đó là dữ liệu trong 'RFArray.' Tôi rất mới để viết mã và không thể nhìn thấy những gì tôi đã làm, xin vui lòng giúp đỡ.
Cảm ơn bạn rất nhiều, có ý nghĩa hoàn hảo, cảm ơn bạn đã giải thích. Làm việc lần đầu – samp17