方法一: -(UIWindow *)topLevelWindowGet { UIWindow *topView = [UIApplication sharedApplication].keyWindow; for (UIWindow *win in [[UIApplication sharedApp ...
分类:
移动开发 时间:
2019-09-17 11:01:03
阅读次数:
200
1 2 3 4 5 6 7 8 9 func rootViewCon() -> UIViewController { var topVC = UIApplication.shared.keyWindow?.rootViewController while topVC?.presentedViewCo ...
分类:
移动开发 时间:
2018-03-12 10:24:52
阅读次数:
246
//获取到当前所在的视图 - (UIViewController *)presentingVC:(UIApplication *)application{ UIWindow * window = application.keyWindow; if (window.windowLevel != UIW ...
分类:
移动开发 时间:
2018-01-02 18:48:40
阅读次数:
176
发送触摸事件后, 系统会将事件添加到系统UIApplication的事件管理队列中 UIApplication会在事件队列的最前端取出事件,然后分发下去,以便处理, 通常会把事件首先分发给KeyWindow处理 KeyWindow会在视图层次中找到一个最合适的视图来处理触摸事件,这也是处理事件过程的 ...
分类:
其他好文 时间:
2017-09-22 00:55:59
阅读次数:
133
+ (UIViewController *)getCurrentVC { UIWindow * window = [[UIApplication sharedApplication] keyWindow]; if (window.windowLevel != UIWindowLevelNormal)... ...
分类:
其他好文 时间:
2017-04-29 11:55:02
阅读次数:
148
对于在UIView上,是不能跳转的,所以我们通常要借助UIViewController,但经常会出现UIViewController没被加载的情况。这时就会报这个错。 解决方法: viewCon = (UIApplication.shared.keyWindow?.rootViewControlle ...
之前想要拿到app的窗口,我们通常的写法是: [UIApplication sharedApplication].keyWindow 这种写法之前一直也觉得是正确的,没什么问题,而且网上大多数的博客或者资料中也是这样写的,但是最近在项目,发现这样写是不安全的,如果应用程序没有跳转,这种写法还算是可行 ...
分类:
移动开发 时间:
2017-01-04 10:50:08
阅读次数:
207
首先我们追踪UIStatusBar的触摸事件,需要在AppDelegate里面加入以下代码 然后在statusBarTouchedAction方法中将显示在当前keyWindow里面的scrollView滚动到顶部 [[DDTopWindow defaultDDTopWindow] scrollsT ...
分类:
移动开发 时间:
2016-12-27 16:04:37
阅读次数:
241
一般来说 [UIApplication sharedApplication].keyWindow.rootViewController 会在 appDelegate 中初始化,并且整个应用运行过程中都不会变。 所以在很多地方需要用 presentModelViewController 方法时,用这个 ...
分类:
移动开发 时间:
2016-11-03 14:19:40
阅读次数:
384
事件处理的整个流程总结: 1.触摸屏幕产生触摸事件后,触摸事件会被添加到由UIApplication管理的事件队列中(即,首先接收到事件的是UIApplication)。 2.UIApplication会从事件队列中取出最前面的事件,把事件传递给应用程序的主窗口(keyWindow)。 3.主窗口会 ...
分类:
其他好文 时间:
2016-10-12 16:44:23
阅读次数:
191