在 iPad 上的模态视图上插入子视图
如何以编程方式访问封装在 iPad 上模态视图中的视图的大小?
我使用 UIModalPresentationFormSheet 枚举在 Ipad 上呈现模式视图,并且在某一时刻我想在整个模式表上临时呈现活动指示器视图,直到发生操作。我遇到的问题是我正在使用视图控制器视图的框架初始化此等待指示器视图,并且无论出于何种原因,该框架始终显示为(0,0,320,460)。虽然这对于 iPhone 来说没问题,但在 iPad 上,模式表单显然比这要大,因此我的活动指示器仅部分覆盖了屏幕。关于如何填写模式表单有什么想法吗?
感谢您的帮助。
How can I programmatically get access to the size of the a view that is encapsulated within a modal view on the iPad?
I am presenting a modal view on the Ipad using the UIModalPresentationFormSheet enumeration, and at one point I would like to temporarily present an activity indicator view over the entire modal sheet until an action occurs. The problem I am having is I am initializing this waiting indicator view with the frame of the view controller's view, and for whatever reason, that frame is always showing up as (0,0,320,460). While this is fine for the iPhone, on the iPad, the modal form sheet is obviously bigger than that, and so my activity indicator is only partly covering the screen. Any ideas on how to fill the modal form sheet?
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为最好的方法是添加视图控制器的 xib 活动指示器。我以前曾经这样做过,而且对我来说效果很好。
1) 只需在 xib 中添加整个视图的视图即可。
2) 将背景颜色设置为黑色并且大约 20% 不透明。这会给你一个阴影覆盖。
3)在Interface Builder的第三个选项卡上,您可以看到自动调整大小的信息。打开所有支柱和弹簧(确保所有 6 条线都变成红色)。这将确保无论弹出窗口的大小如何,视图都会调整大小以填充整个弹出窗口。
4) 将您的活动指示器添加到该覆盖视图中。在第三个选项卡的放置部分中,使用这些按钮将其水平和垂直居中。
5) 对于活动指示器,关闭所有支柱和弹簧。这意味着它不会调整大小,但它会始终漂浮在视图的中心。
6) 将 IBOutlet 添加到视图控制器中的覆盖视图并将其附加到 xib 中。
7) 然后,当您加载所需的任何数据并想要删除活动指示器时,可以将覆盖视图设置为隐藏,以将其从弹出窗口的视图中完全删除。
I think the best way to do this is to add the activity indicator your view controller's xib. I've done this before and it works out well for me.
1) Just add a view over the entire view in your xib.
2) Make the background color if black and about 20% opaque. That will give you a shadowy overlay.
3) On the third tab in Interface Builder, you can see the autosizing information. Turn on all of the struts and springs (make sure all 6 of the lines are turned red). That will ensure the view will resize to fill the entire popover no matter what size the popover becomes.
4) Add your activity indicator into that overlay view. On the 3rd tab, in the placement section, use those buttons to center it horizontally and vertically.
5) For the activity indicator, turn OFF all of the struts and springs. That means it won't resize, but it will float in the center of the view at all times.
6) Add an IBOutlet to the overlay view in your view controller and attach it in the xib.
7) Then when you've loaded whatever data you need and want to remove the activity indicator, either set the overlay view to hidden to remove it entirely from the popover's view.