-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeWindow.h
80 lines (68 loc) · 3.05 KB
/
makeWindow.h
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
// makeWindow.h
// h5gg
//
// Created by admin on 24/4/2022.
//
#ifndef makeWindow_h
#define makeWindow_h
#pragma GCC diagnostic ignored "-Wnullability-completeness"
UIWindow* makeWindow(NSString* clazz)
{
UIWindow* w = nil;
if (@available(iOS 13.0, *)) {
UIWindowScene* theScene=nil;
for (UIWindowScene* windowScene in [UIApplication sharedApplication].connectedScenes) {
NSLog(@"windowScene=%@ %@ state=%ld", windowScene, windowScene.windows, (long)windowScene.activationState);
if(!theScene && windowScene.activationState==UISceneActivationStateForegroundInactive)
theScene = windowScene;
if (windowScene.activationState == UISceneActivationStateForegroundActive) {
theScene = windowScene;
break;
}
}
w = [[NSClassFromString(clazz) alloc] initWithWindowScene:theScene];
}else{
CGRect frame = [UIScreen mainScreen].bounds; //在iPad分屏或浮动模式下, 后面会被resize成真实尺寸
w = [[NSClassFromString(clazz) alloc] initWithFrame:frame];
NSLog(@"makeWindow=frame=%@", NSStringFromCGRect(w.frame));
}
return w;
}
@implementation UIWindow(GVWindow)
//这个在ipad支持悬浮模式的app中会触发两次viewWillTransitionToSize
- (void)private_updateToInterfaceOrientation:(UIInterfaceOrientation)orientation animated:(BOOL)animated
{
NSLog(@"private_updateToInterfaceOrientation=%ld %d %@", (long)orientation, animated, self);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundeclared-selector"
SEL mySelector = @selector(_updateToInterfaceOrientation:animated:);
#pragma clang diagnostic pop
NSMethodSignature * sig = [[self class] instanceMethodSignatureForSelector:mySelector];
NSInvocation * myInvocation = [NSInvocation invocationWithMethodSignature: sig];
[myInvocation setTarget:self];
[myInvocation setSelector: mySelector];
[myInvocation setArgument:&orientation atIndex: 2];
[myInvocation setArgument:&animated atIndex: 3];
[myInvocation retainArguments];
[myInvocation invoke];
}
//- (void)private_updateToInterfaceOrientation:(UIInterfaceOrientation)orientation duration:(float)duration force:(BOOL)force
//{
// NSLog(@"private_updateToInterfaceOrientation=%d %d %@", orientation, force, self);
//#pragma clang diagnostic push
//#pragma clang diagnostic ignored "-Wundeclared-selector"
// SEL mySelector = @selector(_updateToInterfaceOrientation:duration:force:);
//#pragma clang diagnostic pop
// NSMethodSignature * sig = [[self class] instanceMethodSignatureForSelector:mySelector];
// NSInvocation * myInvocation = [NSInvocation invocationWithMethodSignature: sig];
// [myInvocation setTarget:self];
// [myInvocation setSelector: mySelector];
// [myInvocation setArgument:&orientation atIndex: 2];
// [myInvocation setArgument:&duration atIndex: 3];
// [myInvocation setArgument:&force atIndex: 4];
// [myInvocation retainArguments];
// [myInvocation invoke];
//}
@end
#endif /* makeWindow_h */