简体   繁体   English

在iOS 8.3中将子视图添加到UIWindow

[英]Adding subview to UIWindow in iOS 8.3

In one place in my app i was adding an overlay to the key window as a overlay.After updating my iPad to 8.4 that stopped working.Is there anything that needs to be considered that has been changed over the iOS Versions? 在我的应用程序中的一个地方,我在键盘窗口中添加了一个覆盖层作为覆盖层。将iPad更新到8.4不能正常工作后,是否需要考虑在iOS版本上进行过任何更改?

    UIApplication.sharedApplication().delegate?.window!!.addSubview(thankYouOverlayView)

PS thankYouOverlayView can be added to self.view as subview but i need it to be at the top level. PSthankYouYouOverlayView可以添加到self.view作为子视图,但我需要它在顶层。

As others have stated, adding directly to the window is generally not a good idea. 正如其他人所说,直接添加到窗口通常不是一个好主意。 You can do it, but it's better to have a specific view and view controller that you're adding the view to. 可以做到,但是最好有一个特定的视图和要添加视图的视图控制器。

What I have found to be effective is to create a loop that finds the top most view and view controller and add the view to that. 我发现有效的是创建一个循环,该循环查找最顶部的视图和视图控制器,并将视图添加到其中。 I've never had an issue with that from iOS 6 up through the current iOS 9 beta. 从iOS 6到当前的iOS 9 Beta,我从没有遇到过问题。

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

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