Swift UITableView set rowHeight [question on SO]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyController: UITableViewController, UITableViewDelegate, UITableViewDataSource { | |
// ... | |
var sizingSectionCell: SectionTableViewCell? | |
// ... | |
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { | |
var onceToken: dispatch_once_t = 0 | |
dispatch_once(&onceToken) { | |
self.sizingSectionCell = self.sectionsView.dequeueReusableCellWithIdentifier(self._sectionCellReuseIdentifier) as? SectionTableViewCell | |
} | |
var section = chapter!.sections[indexPath.row] | |
sizingSectionCell?.speakerLabel?.text = section.speaker | |
sizingSectionCell?.contentLabel.text = section.content | |
sizingSectionCell?.meaningLabel.text = section.meaning | |
sizingSectionCell?.setNeedsLayout() | |
sizingSectionCell?.layoutIfNeeded() | |
let size: CGSize = sizingSectionCell!.contentView.systemLayoutSizeFittingSize(UILayoutFittingCompressedSize) | |
return size.height | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Crashes everytime at the line ... self.sizingSectionCell = self.sectionsView.dequeueReusableCellWithIdentifier(self._sectionCellReuseIdentifier) as? SectionTableViewCell