iOS UIView旋转后获取框架 [英] iOS UIView get frame after rotation

查看:127
本文介绍了iOS UIView旋转后获取框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

方向更改后,我试图获取UIView的大小.在我的视图控制器中,我实现了didRotateFromInterfaceOrientation:并在我的视图上调用了setNeedsLayout:.在我的视图的layoutSubviews方法中,它尝试根据旋转后的新帧大小执行一些逻辑,但是帧大小尚未更新以反映新的方向(例如,移到横向后,它仍然是768x1024而不是1024x768) .

I'm trying to get the size of my UIView after the orientation changes. In my view controller I implement didRotateFromInterfaceOrientation: and call setNeedsLayout: on my view. In my view's layoutSubviews method, it tries to perform some logic based on its new frame size post rotation, but the frame size has not been updated to reflect the new orientation (e.g. it is still 768x1024 instead of 1024x768 after moving to landscape).

如何获取更新的框架尺寸?

How do I get the updated frame size?

推荐答案

只需回答路易斯·奥斯卡(Luis Oscar)所说的话,问题就会显示为已回答. 解决方案是访问"bounds"属性,而不是"frame".

Just going to answer with what Luis Oscar said so that the question shows up as answered. The solution is to access the "bounds" property rather than "frame".

这篇关于iOS UIView旋转后获取框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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