UITableView tableFooterView weird resizing

老子叫甜甜 提交于 2019-12-03 16:59:57
Michael Kessler

No matter what width you set to the view that you are adding as a UITableView footer/header - its width always will be the same as the table's width.

So, in your case the view that you've added is resized to CGRectMake(0, 0, 320, 50), but the button remains with the correct frame. Button's frame is according to the view...

EDIT:
The only parameter in footer's/header's frame that remains as you set it is the height.

Notice that if you will change the height of the header/footer view after it is added to the table it won't make any change. You should set the height before adding it to the table...

There is actually a way which I came across trying to overcome this problem;

Create an empty UIView 320x(the height of your button) and then place the button centred inside this containing view. This way the button inside the view doesn't get resized.

Hope this helps,

Jonathan

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