设备旋转手动旋转视图
我使用此方法根据方向手动旋转一些视图和子视图:
CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(0);
landscapeTransform = CGAffineTransformTranslate( landscapeTransform, 0.0, 0.0 );
[self.navigationController.view setTransform:landscapeTransform];
CGRect theFrame = self.view.bounds;
self.navigationController.view.frame= CGRectMake(0, 0, 320, 480);
现在这适用于从横向旋转到纵向,但如果我尝试旋转到横向,则框架 CGRect 没有任何逻辑意义(它看起来像这样) (200,-50,宽度,高度)。我还必须硬设置纵向框架,如果我得到 self.view.frame 或边界或其他我检查的框架,它会在每次旋转时发生变化
。有没有更好的方法来设置更符合逻辑而不是硬编码的框架?
I am manually rotating a few views and subviews depending on orientation using this method:
CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(0);
landscapeTransform = CGAffineTransformTranslate( landscapeTransform, 0.0, 0.0 );
[self.navigationController.view setTransform:landscapeTransform];
CGRect theFrame = self.view.bounds;
self.navigationController.view.frame= CGRectMake(0, 0, 320, 480);
Now this works for rotating from landscape to portrait but if I try and rotate to landscape the frame CGRect doesn't make any logical sense (it looks like its something like (200,-50, width, height). I also have to hard set the frame for portrait, if I get the frame for self.view.frame or bounds or anything else I check, it changes each time I rotate.
Is there any better way to set the frame thats more logical and not hard coded?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论