objective-c - 视图view.window返回当前keywindow吗?
ringa_lee
ringa_lee 2017-04-21 11:16:44
[iOS讨论组]

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

ringa_lee
ringa_lee

ringa_lee

全部回复(4)
PHP中文网

我觉得UIView.window返回的是当前view所在的那个window,未必是keywindow

高洛峰
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.
大家讲道理

万一view是键盘上的某一块,view.window就是键盘的window。

怪我咯

不一定是。

可通过view.window.keyWindow判断。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号