Skip to content

Commit cc1d97d

Browse files
Merge remote-tracking branch 'refs/remotes/origin/main'
2 parents 751281d + 16ca898 commit cc1d97d

3 files changed

Lines changed: 11 additions & 14 deletions

File tree

Natives/UIKit+hook.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#import <UIKit/UIKit.h>
22

3-
#define realUIIdiom UIDevice.currentDevice.hook_userInterfaceIdiom
3+
#define realUIIdiom UIDevice.currentDevice.userInterfaceIdiom
44
extern NSNotificationName UIPresentationControllerPresentationTransitionWillBeginNotification;
55

66
@interface UIDevice(hook)
77
- (NSString *)completeOSVersion;
8-
- (UIUserInterfaceIdiom)hook_userInterfaceIdiom;
98
@end
109

1110
@interface UIImageView(hook)
@@ -27,12 +26,17 @@ extern NSNotificationName UIPresentationControllerPresentationTransitionWillBegi
2726

2827
@interface UIDevice(private)
2928
- (NSString *)buildVersion;
29+
- (void)_setActiveUserInterfaceIdiom:(NSInteger)idiom;
3030
@end
3131

3232
@interface UIImage(private)
3333
- (UIImage *)_imageWithSize:(CGSize)size;
3434
@end
3535

36+
@interface UIScreen(private)
37+
- (void)_setUserInterfaceIdiom:(NSInteger)idiom;
38+
@end
39+
3640
@interface UITextField(private)
3741
@property(assign, nonatomic) NSInteger nonEditingLinebreakMode;
3842
@end

Natives/UIKit+hook.m

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ void swizzleUIImageMethod(SEL originalAction, SEL swizzledAction) {
2929
}
3030

3131
void init_hookUIKitConstructor(void) {
32-
swizzle(UIDevice.class, @selector(userInterfaceIdiom), @selector(hook_userInterfaceIdiom));
32+
UIUserInterfaceIdiom idiom = getPrefBool(@"debug.debug_ipad_ui") ? UIUserInterfaceIdiomPad : UIUserInterfaceIdiomPhone;
33+
[UIDevice.currentDevice _setActiveUserInterfaceIdiom:idiom];
34+
[UIScreen.mainScreen _setUserInterfaceIdiom:idiom];
35+
3336
swizzle(UIImageView.class, @selector(setImage:), @selector(hook_setImage:));
3437
if(UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
3538
swizzle(UIPointerInteraction.class, @selector(_updateInteractionIsEnabled), @selector(hook__updateInteractionIsEnabled));
@@ -58,16 +61,6 @@ - (NSString *)completeOSVersion {
5861
return [NSString stringWithFormat:@"%@ %@ (%@)", self.systemName, self.systemVersion, self.buildVersion];
5962
}
6063

61-
- (UIUserInterfaceIdiom)hook_userInterfaceIdiom {
62-
if (getPrefBool(@"debug.debug_ipad_ui")) {
63-
return UIUserInterfaceIdiomPad;
64-
} else if (self.hook_userInterfaceIdiom == UIUserInterfaceIdiomTV) {
65-
return self.hook_userInterfaceIdiom;
66-
} else {
67-
return UIUserInterfaceIdiomPhone;
68-
}
69-
}
70-
7164
@end
7265

7366
// Patch: emulate scaleToFill for table views

Natives/main.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,10 @@ int main(int argc, char *argv[]) {
296296
init_redirectStdio();
297297
init_logDeviceAndVer(argv[0]);
298298

299+
loadPreferences(NO);
299300
init_hookFunctions();
300301
init_hookUIKitConstructor();
301302

302-
loadPreferences(NO);
303303
debugLogEnabled = getPrefBool(@"general.debug_logging");
304304
NSLog(@"[Debugging] Debug log enabled: %@", debugLogEnabled ? @"YES" : @"NO");
305305

0 commit comments

Comments
 (0)