objective-c - 视图view.window返回当前keywindow吗?

 手机用户2502859805 发布于 2022-10-25 02:31

UIView.window属性来源于当前UIApplication.keyWindow,可以通过此属性让UIView间接获取到该视图的UIViewController类。

4 个回答
  • 不一定是。

    可通过view.window.keyWindow判断。

    2022-11-12 01:39 回答
  • 万一view是键盘上的某一块,view.window就是键盘的window。

    2022-11-12 01:39 回答
  • self.view.window 只是当前view的window,可能是keywindow
    @property(nonatomic, readonly) UIWindow *window
    Description	
    The receiver’s window object, or nil if it has none. (read-only)
    This property is nil if the view has not yet been added to a window.
    [[UIApplication sharedApplication] keyWindow]
    @property(nonatomic, readonly) UIWindow *keyWindow
    This property holds the UIWindow object in the windows array that is most recently sent the makeKeyAndVisible message.
    [[UIApplication sharedApplication] windows]
    @property(nonatomic, readonly) NSArray *windows
    This property returns an array of the application's visible and hidden windows. The windows are ordered back to front.
    2022-11-12 01:39 回答
  • 我觉得UIView.window返回的是当前view所在的那个window,未必是keywindow

    2022-11-12 01:39 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有