出于某种原因,当我尝试在ContainerView中嵌入的UITableViewController
上重新加载数据时,它从不调用numberOfRowsForIndex
或cellForRowAtIndex
。
class SelectedDatesTableViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.preferredContentSize.height = CGFloat( SelectedDatesTimeAway.selectedDates.count * 44 )
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return SelectedDatesTimeAway.selectedDates.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = self.tableView.dequeueReusableCellWithIdentifier("dateCell")! as UITableViewCell
let dateFormatter = NSDateFormatter()
dateFormatter.dateStyle = .ShortStyle
dateFormatter.timeStyle = .NoStyle
cell.textLabel?.text! = dateFormatter.stringFromDate(SelectedDatesTimeAway.selectedDates[indexPath.row])
return cell
}
func reloadTable() {
self.preferredContentSize.height = CGFloat( SelectedDatesTimeAway.selectedDates.count * 44 )
self.tableView.reloadData()
}
}