简体   繁体   English

TableView Rotation调整子视图的大小

[英]TableView Rotation resizes subviews

My app supports both portrait and landscape mode. 我的应用程序同时支持纵向和横向模式。 I have a TableViewController that has some issues when i rotate from portrait mode to landscape mode. 我有一个TableViewController ,当我从纵向模式旋转到横向模式时遇到了一些问题。 I want subviews of TableView not to change neither orientation nor size. 我希望TableView的子视图不改变方向或大小。 But i cannot find the way. 但是我找不到路。 I tried from storyboard to uncheck Autoresize subviews but it did not work. 我尝试从情节提要中取消选中“自动调整大小”子视图,但是它不起作用。 My TableView is into a TabBarController . 我的TableView进入TabBarController It is strange, that in another ViewController i have a similar TableView with exactly the same attributes that works fine. 奇怪的是,在另一个ViewController中,我有一个具有完全相同的属性且工作正常的类似TableView。 So i added some pics with the problem and with what i want. 所以我添加了一些有关问题以及我想要的照片。

The only code that handles TableView orientation changes is in viewDidLoadMethod the below: 以下是viewDidLoadMethod中唯一处理TableView方向更改的代码:

    self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

The first image is from Portrait mode 第一张图片来自人像模式

人像模式

The second from troublesome Landscape mode 麻烦的风景模式中的第二个

风景模式

And the third from the right TableViewController and the result that i want 第三,来自正确的TableViewController和我想要的结果

预期结果

Any advice would be helpful. 任何意见将是有益的。

您可以做的是在imageView上设置约束,并强制宽度和高度保持固定。

The issue was in size inspector. 问题出在尺寸检查器中。 I had to keep autoresizing of ImageView only TopLeft. 我必须保持ImageView仅TopLeft的自动调整大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM