Wrong width of custom section header form xib

坚强是说给别人听的谎言 提交于 2019-12-12 04:24:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!