自定义节标题格式Xib的宽度错误 [英] Wrong width of custom section header form xib

查看:66
本文介绍了自定义节标题格式Xib的宽度错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在不同的屏幕尺寸下,我无法使视图的宽度适应表格视图的大小

I can't manage to make the view's width adapt to the size of the table view on different screen sizes

这是我在viewDidLoad()上的代码

Here's my code on viewDidLoad()

    view.tableView.registerNib(UINib(nibName: "Header", bundle: NSBundle.mainBundle()), forHeaderFooterViewReuseIdentifier: "Header")

在表格视图"委托上:

  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.

有什么提示吗?

推荐答案

我的xib由一个UITableViewCell组成.我用UIView代替了它,它解决了我的问题

My xib consisted of a UITableViewCell. I replaced it by a UIView and it solved my problem

这篇关于自定义节标题格式Xib的宽度错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆