File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed
DWBasicAlertActionDemo/DWBasicAlertActionDemo/DWBasicAlertAction Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change 8
8
// 弹窗显示工具
9
9
10
10
#import " DWBasicAlertAction.h"
11
- #import " AppDelegate.h"
11
+ // #import "AppDelegate.h"
12
12
#import < objc/runtime.h>
13
13
14
14
@implementation DWBasicAlertAction
@@ -142,9 +142,10 @@ + (UIViewController *)getPresentViewController {
142
142
因为UIAlertController的出现,是生成了一个新的window,然后添加在界面上
143
143
这个时候获取到的keyWindow就是UIAlertControllerShimPresenterWindow
144
144
获取到的rootViewController就会是UIApplicationRotationFollowingController */
145
- AppDelegate *appdelegate = (AppDelegate *)[UIApplication sharedApplication ].delegate ;
146
- UIViewController *topController = appdelegate.window .rootViewController ;
147
-
145
+ // AppDelegate *appdelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
146
+ // UIViewController *topController = appdelegate.window.rootViewController;
147
+ UIViewController *topController = [[[UIApplication sharedApplication ] keyWindow ] rootViewController ];
148
+
148
149
// Getting topMost ViewController
149
150
while ([topController presentedViewController ]) {
150
151
topController = [topController presentedViewController ];
Original file line number Diff line number Diff line change 8
8
// 弹窗显示工具
9
9
10
10
#import " DWBasicAlertAction.h"
11
- #import " AppDelegate.h"
11
+ // #import "AppDelegate.h"
12
12
#import < objc/runtime.h>
13
13
14
14
@implementation DWBasicAlertAction
@@ -142,9 +142,10 @@ + (UIViewController *)getPresentViewController {
142
142
因为UIAlertController的出现,是生成了一个新的window,然后添加在界面上
143
143
这个时候获取到的keyWindow就是UIAlertControllerShimPresenterWindow
144
144
获取到的rootViewController就会是UIApplicationRotationFollowingController */
145
- AppDelegate *appdelegate = (AppDelegate *)[UIApplication sharedApplication ].delegate ;
146
- UIViewController *topController = appdelegate.window .rootViewController ;
147
-
145
+ // AppDelegate *appdelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
146
+ // UIViewController *topController = appdelegate.window.rootViewController;
147
+ UIViewController *topController = [[[UIApplication sharedApplication ] keyWindow ] rootViewController ];
148
+
148
149
// Getting topMost ViewController
149
150
while ([topController presentedViewController ]) {
150
151
topController = [topController presentedViewController ];
You can’t perform that action at this time.
0 commit comments