以编程方式确定 iPad 模态视图的大小
我有一个 iPad 应用程序,它呈现模式视图。我想对模态视图的控件进行一些编程操作,但我找不到获取模态视图大小的方法。如果我调用 View.Bounds 或 View.Frame,它会给我整个屏幕的边界/框架(即 1024x768) - 但我通过测量自己知道模态视图实际上约为 540x620。
虽然我知道我可以自己对此进行硬编码,但这让我感觉很脏......是否有一种编程方式可以让模态视图获得自己的“真实”大小?
谢谢
约翰
I've got an iPad application which presents a modal view. I'd like to do some programmatic manipulation of the modal view's controls, but I can't find the way to get the modal view's size. If I call View.Bounds or View.Frame it gives me the bounds/frame for the whole screen (i.e. 1024x768) - but I know from measuring myself that the modal view is actually about 540x620.
While I know I can hard-code this in myself, this makes me feel dirty... is there a programmatic way for a modal view to get its own 'real' size?
Thanks
John
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过设置
modalPresentationStyle
?然后您应该从 modalController.view.frame 获取正确的帧大小 (540 x 620)。
Have you tried setting
modalPresentationStyle
?Then you should get the correct frame size (540 x 620) from
modalController.view.frame
.谢谢。问题实际上是我试图在 ViewDidLoad 方法中获取大小,而不是 ViewDidAppear (那个总是让我......)。在 ViewDidLoad 中,它返回 1024x768 大小,但是当我将代码移至 ViewDidAppear 中时,它开始返回正确的 (540x620) 大小!
Thanks. The problem was actually that I was trying to get the size in the ViewDidLoad method, rather than ViewDidAppear (that one always gets me...). In ViewDidLoad it was returning the 1024x768 size, but when I moved my code into ViewDidAppear, it started returning the correct (540x620) size!