简体   繁体   English

将子视图添加到UIWindow有什么缺点?

[英]What are the disadvantages of adding subview to UIWindow?

I am new to ios developement, actually i want to add UICollectionView to top of everything. 我是ios developpement的新手,实际上我想将UICollectionView添加到所有内容之上。 So, for that i am adding this to UIWindow, what basically i want to know that is there any disadvantage to adding UICollectionView to UIWindow. 所以,为此我将其添加到UIWindow,基本上我想知道的是将UICollectionView添加到UIWindow有什么不利之处。 If yes then, Is there any way of adding any object to the top of everything? 如果是,那么,有没有办法将任何对象添加到所有内容的顶部? Thanks. 谢谢。

Usually the idea of the UIWindow is to hold 1 rootViewController and not play with that too much, only use it in cases you need to get the main view. 通常,UIWindow的想法是保存1个rootViewController而不是太多玩,只在需要获取主视图的情况下使用它。

The right way to do so is to have 1 main NavigationController and to override it with what-ever kind of top view you want (ie side menu, various overlays, etc..), this way its always accessible from the subControllers and you have a complete handling of that inside a UIViewController with all of the relevant delegate methods. 正确的方法是拥有1个主导航控制器,并用你想要的任何顶视图覆盖它(即侧面菜单,各种叠加等等),这样它总是可以从子控制器访问,你有在UIViewController中使用所有相关的委托方法完全处理它。

除此之外,它通常被认为是不好的做法, UIKit应该为您提供另一种方法来避免这种用法,我能想到的最大问题是直接添加到UIWindow视图不响应设备方向的变化(旋转)事件,不会与UI的其余部分一起旋转。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM