Last active
December 16, 2015 18:40
-
-
Save iolate/5479906 to your computer and use it in GitHub Desktop.
[THEOS] Additional UIWindows - Rotating UIWindow when orientation was changed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define UPDATE_ORIENTATION_NOTI CFSTR("iolate/UpdateOrientation") | |
static UIWindow* additionalWindow = nil; | |
static UIView* mainViewInWindow = nil; | |
static void updateOrientation(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { | |
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; | |
int orientation_ = 0; | |
switch (orientation) { | |
case UIInterfaceOrientationPortraitUpsideDown: | |
orientation_ = 180; | |
break; | |
case UIInterfaceOrientationLandscapeLeft: | |
orientation_ = -90; | |
break; | |
case UIInterfaceOrientationLandscapeRight: | |
orientation_ = 90; | |
break; | |
case UIInterfaceOrientationPortrait: | |
default: | |
orientation_ = 0; | |
} | |
[UIView animateWithDuration:0.3f animations:^{ | |
additionalWindow.transform = CGAffineTransformMakeRotation(orientation_ * M_PI / 180.0f); | |
[additionalWindow setFrame:[[UIScreen mainScreen] bounds]]; | |
[mainViewInWindow setFrame:[beeWindow bounds]]; | |
} completion:nil]; | |
} | |
%ctor { | |
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, &updateOrientation, UPDATE_ORIENTATION_NOTI, NULL, CFNotificationSuspensionBehaviorCoalesce); | |
additionalWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; | |
mainViewInWindow = [[UIView alloc] initWithFrame:[beeWindow bounds]]; | |
[mainViewInWindow setAutoresizesSubviews:YES]; | |
[additionalWindow addSubview:mainViewInWindow]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define UPDATE_ORIENTATION_NOTI CFSTR("iolate/UpdateOrientation") | |
%hook SpringBoard | |
-(void)frontDisplayDidChange { | |
//iOS3.2-5 | |
%orig; | |
CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), UPDATE_ORIENTATION_NOTI, NULL, NULL, true); | |
} | |
- (void)noteInterfaceOrientationChanged:(int)orientation { | |
//iOS3.2-5 | |
%orig; | |
CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), UPDATE_ORIENTATION_NOTI, NULL, NULL, true); | |
} | |
-(void)noteInterfaceOrientationChanged:(int)orientation duration:(double)duration { | |
//iOS6 | |
%orig; | |
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC / 5); | |
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ | |
CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), UPDATE_ORIENTATION_NOTI, NULL, NULL, true); | |
}); | |
} | |
%end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You shouldn't be setting the frame of a UIView when the transform is not identity; the result is undefined