[英]Resize UIView and rotate when change orientation
我有一个显示在屏幕上的viewController,并且使用- (UIInterfaceOrientationMask)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; }
将方向设置为“横向”。 - (UIInterfaceOrientationMask)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; }
- (UIInterfaceOrientationMask)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; }
在此viewController的视图的同一Xib文件中,我有另一个视图设置在顶部,例如此法线控件。该视图本身不应旋转,但是当我改变方向时,我希望此视图将滑块旋转并转到顶部。
我收到使用[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
更改方向的通知[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
首先,我尝试使用view.bounds = CGRectMake(0, 0, newWidth, 44);
来更改此视图框架的宽度view.bounds = CGRectMake(0, 0, newWidth, 44);
并使用变换旋转它,但是在调整宽度后我得到了类似的东西
显然,我丢失了视图右侧的内容,但我不知道为什么(因为我在界面生成器中施加了一些约束,这些约束告诉标签保留在视图右侧的权利)
之后,我尝试缩放视图,但是却得到了类似的信息[我不能发布两个以上的链接,但是视图中的所有内容都会变小(这正是缩放应该执行的操作,但不是我想要的)]。 我希望左右的标签保持相同的宽度,并且当我调整视图宽度的大小时,只有滑块变小。
有人知道我在做什么错吗?
谢谢!!
您应该使用autolayout
。 为该滑块提供顶部,前导,尾随和固定高度限制,它将同时管理纵向和横向。 希望这会有所帮助:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.