Skip to content

Instantly share code, notes, and snippets.

@JatWaston
Forked from iolate/AdditionalUIWindow.xm
Created August 11, 2014 10:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JatWaston/ff565feb0bbfc746ea48 to your computer and use it in GitHub Desktop.
Save JatWaston/ff565feb0bbfc746ea48 to your computer and use it in GitHub Desktop.
#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];
}
#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