-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGTFingerTipOverlayWindow.m
50 lines (40 loc) · 1.62 KB
/
GTFingerTipOverlayWindow.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#import "GTFingerTipOverlayWindow.h"
@interface GTFingerTipOverlayWindow ()
@property (nonatomic) NSTimer *removeViewTimer;
@end
@implementation GTFingerTipOverlayWindow
// UIKit tries to get the rootViewController from the overlay window.
// Instead, try to find the rootViewController on some other application window.
// Fixes problems with status bar hiding, because it considers the overlay window a candidate for controlling the status bar.
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
_removeViewTimer = [[NSTimer scheduledTimerWithTimeInterval:5.0
target:self
selector:@selector(removeSubviews:)
userInfo:nil
repeats:YES] retain];
}
return self;
}
- (void)dealloc {
[self.removeViewTimer release];
[super dealloc];
}
- (void)removeSubviews:(NSTimer *)sender {
[self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
}
- (UIViewController *)rootViewController
{
NSLog(@"entering getrootView");
for (UIWindow *window in [[UIApplication sharedApplication] windows])
{
if (self == window || ![window isKeyWindow])
continue;
UIViewController *realRootViewController = window.rootViewController;
if (realRootViewController != nil)
NSLog(@"exiting getrootView");
return realRootViewController;
}
return [super rootViewController];
}
@end