在iOS中我们可以同时向一个窗口添加多个子视图吗?
是否可以向给定窗口添加 1 个以上子视图。例如。 [window addsubview: subview1] [window addsubview: subview2]
其中视图之一是 UIViewController。 我尝试这样做,但 UIViewController 视图覆盖了其他子视图。
Is it possible to add more than 1 subviews to a given window. Eg. [window addsubview: subview1] [window addsubview: subview2]
where one of the views is UIViewController.
I tried doing it but the UIViewController view overrides the other subview.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
确保两个视图的大小不同,这样它们就不会相互重叠。尝试将一个视图的 x 和 y 位置以及背景颜色更改为与另一个视图不同的颜色,看看我的意思。
快速浏览一下 UIWindow文档会透露它继承自 UIView,您可以向其中添加任意数量的子视图。
Make sure both the views do not have the same size, so they do not overlap each other. Try changing one view's x and y location and background colour to something that stands out from the other one to see what I mean.
A quick look at the UIWindow docs would have revealed it inherited from UIView, to which you can add an arbitrary number of subviews.
是的,您可以向
UIWindow
添加多个子视图。对于您的问题,请检查您添加的视图的框架 - 可能您的 viewController 的视图是全屏的,而另一个视图就在它的下面
Yes you can add multiple subviews to
UIWindow
.For your problem check the frames of the views you add - probably your viewController's view is fullscreen and another view is just under it