问题
I can't manage to make the view's width adapt to the size of the table view on different screen sizes
Here's my code on viewDidLoad()
view.tableView.registerNib(UINib(nibName: "Header", bundle: NSBundle.mainBundle()), forHeaderFooterViewReuseIdentifier: "Header")
And on the Table View Delegate:
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
var cell = tableView.dequeueReusableHeaderFooterViewWithIdentifier("Header") as! Header
// etc
}
Keep in mind that I don't want to put this in a Storyboard and that I am using Auto Layout.
Any tips?
回答1:
My xib consisted of a UITableViewCell. I replaced it by a UIView and it solved my problem
来源:https://stackoverflow.com/questions/30453545/wrong-width-of-custom-section-header-form-xib