Skip to content

Commit 15177ac

Browse files
committed
Change
1 parent 4a8349f commit 15177ac

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

DWBasicAlertAction/DWBasicAlertAction.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// 弹窗显示工具
99

1010
#import "DWBasicAlertAction.h"
11-
#import "AppDelegate.h"
11+
//#import "AppDelegate.h"
1212
#import <objc/runtime.h>
1313

1414
@implementation DWBasicAlertAction
@@ -142,9 +142,10 @@ + (UIViewController *)getPresentViewController {
142142
因为UIAlertController的出现,是生成了一个新的window,然后添加在界面上
143143
这个时候获取到的keyWindow就是UIAlertControllerShimPresenterWindow
144144
获取到的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+
148149
// Getting topMost ViewController
149150
while ([topController presentedViewController]) {
150151
topController = [topController presentedViewController];

DWBasicAlertActionDemo/DWBasicAlertActionDemo/DWBasicAlertAction/DWBasicAlertAction.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// 弹窗显示工具
99

1010
#import "DWBasicAlertAction.h"
11-
#import "AppDelegate.h"
11+
//#import "AppDelegate.h"
1212
#import <objc/runtime.h>
1313

1414
@implementation DWBasicAlertAction
@@ -142,9 +142,10 @@ + (UIViewController *)getPresentViewController {
142142
因为UIAlertController的出现,是生成了一个新的window,然后添加在界面上
143143
这个时候获取到的keyWindow就是UIAlertControllerShimPresenterWindow
144144
获取到的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+
148149
// Getting topMost ViewController
149150
while ([topController presentedViewController]) {
150151
topController = [topController presentedViewController];

0 commit comments

Comments
 (0)