Statik bir tablo görünümünde dinamik bir tablo görünümü var, ancak ikinci tablomda çağırırken cellForRowAtIndexPath öğesini çağırmak için reloadData'yı alamıyorum. Hücre verilerini ikinci tablo görünümünde doldurmamın bir yolu var mı? Yoksa bunu yapmanın daha iyi bir yolu var mı? Yardımcı olup olmadığını görmek için bir görsel ekledim.multiple tableView reloadData()
import UIKit
import CalendarView
import SwiftMoment
class TimeAwayRequestTableViewController: UITableViewController {
@IBOutlet var calendarView: CalendarView!
@IBOutlet weak var selectedTableView: UITableView!
var selectedDates : [Moment] = []
override func viewDidLoad() {
super.viewDidLoad()
calendarView.delegate = self
selectedTableView.delegate = self
selectedTableView.dataSource = self
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
var returnInt = 0
if tableView == selectedTableView {
returnInt = 10
} else {
if section == 0 {
returnInt = 2
}
if section == 1 {
returnInt = 1
}
}
return returnInt
}
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
var numberOfSections = 0
if tableView == selectedTableView {
numberOfSections = 0
} else {
numberOfSections = 2
}
return numberOfSections
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = UITableViewCell()
if tableView == selectedTableView {
cell = self.tableView.dequeueReusableCellWithIdentifier("dateCell")!
let dateFormatter = NSDateFormatter()
dateFormatter.dateStyle = .ShortStyle
dateFormatter.timeStyle = .NoStyle
let date = selectedDates[indexPath.row].date
cell.textLabel?.text = dateFormatter.stringFromDate(date)
} else {
cell = super.tableView(tableView, cellForRowAtIndexPath: indexPath)
}
return cell
}
}
extension TimeAwayRequestTableViewController : CalendarViewDelegate {
func calendarDidSelectDate(date: Moment) {
selectedDates.append(date)
print(selectedDates)
selectedTableView.frame.size.height = CGFloat(selectedDates.count) * CGFloat(44)
self.tableView.contentSize.height = self.tableView.frame.size.height + self.selectedTableView.frame.size.height
}
func calendarDidPageToDate(date: Moment) {
print(date)
}
}
numbeOfSectionsInTableView öğesinden 0 yerine 1 döndürmeyi deneyin. –