自动调整旋转UITableView的灵活宽度 [英] Auto resizing UITableView on rotation with flexible width

查看:101
本文介绍了自动调整旋转UITableView的灵活宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将UIButtons添加到位于拆分视图控制器右侧的UIView。没有任何自动调整集,按钮文本将以横向方向完全显示。当我旋转到纵向时,所有按钮文本都会完全显示,但是UIView的右侧有额外的空间,因为有更多的空间可供使用。



我希望这些按钮在旋转时调整大小,以便它利用整个宽度。我尝试设置:

  [button setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; 

有了这个,在纵向方向上存在相同的额外空间,但在横向方向上我得到很多按钮,文字缩写为...



如何做到这一点?

解决方案

当AutoResisingMask不为我做的时候,我总是求助于UIView的子类并覆盖layoutSubviews ......这样我就可以手动放置那些在不同方向看起来从不正确的棘手视图事实上,在去年的WWDC上,我听到一位Apple工程师说他总是创建并用框架CGRectZero添加他的观点,然后设置正确的框架在layoutSubviews中。它的价值......


I am adding UIButtons to a UIView located on the right side of a split view controller. Without any autoresizing set, the button text fully displays in landscape orientation. When I rotate to portrait orientation, all button text is fully displayed, but there is extra space on the right hand side of the UIView, because there is more real estate to work with.

I would like these buttons to resize on rotation so that it utilizes the entire width. I tried setting:

[button setAutoresizingMask:UIViewAutoresizingFlexibleWidth];

With this in place, the same extra real estate exists on the portrait orientation, but in landscape orientation I get a lot of buttons with the text shortened with "..."

How can this be done?

解决方案

when the AutoResisingMask doesnt do it for me, I always resort to subclassing the UIView and overriding the layoutSubviews... this way I can manually place those tricky views that never look right in different orientations.

in fact.. at last year's WWDC, I heard an Apple Engineer say that he "always" creates and adds his views with frame CGRectZero, then sets the correct frame in layoutSubviews. For what its worth...

这篇关于自动调整旋转UITableView的灵活宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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