ios - 何时使用 didMoveToWindow 方法?

标签 ios

我一直在寻找这种特殊的方法:didMoveToWindow()但是我还没有找到任何具体的信息。
有人可以解释为什么以及何时应该使用这种方法以及何时调用它?

最佳答案

当 UIView 添加到 Window 对象时,iOS 会调用此方法。
您应该覆盖它以使您的应用程序执行相同的操作。

The default implementation of this method does nothing. Subclasses can override it to perform additional actions whenever the window changes.

The window property may be nil by the time that this method is called, indicating that the receiver does not currently reside in any window. This occurs when the receiver has just been removed from its superview or when the receiver has just been added to a superview that is not attached to a window. Overrides of this method may choose to ignore such cases if they are not of interest.



https://developer.apple.com/reference/uikit/uiview/1622527-didmovetowindow

关于ios - 何时使用 didMoveToWindow 方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36865314/

相关文章:

ios - UITableViewController 页脚内的自定义 UITableView Cell

ios - urlSession :dataTask:didReceive:completionHandler not called in Xcode8 Swift3

ios - 修改后的 EXIF 数据无法正确保存

objective-c - 多线程从何而来?

ios - 如何为AVWriter写入设置CMSampleBuffer的时间戳

ios - 强调字体 swift 的粗体

ios - iPhone X 背景图像的长宽比

ruby-on-rails - 从同一个 api 向 2 个不同的应用程序发送 apn 通知

ios - XCode:使用 define 检查目标平台

ios - 如何让动画在 SwiftUI 的 ScrollView 中工作? SwiftUI 中的 Accordion 风格动画