forked from mirrors/linphone-iphone
Fix landscape start discrepancies on iPad for iOS8.
This commit is contained in:
parent
19b23f1b45
commit
5574cedaea
5 changed files with 67 additions and 66 deletions
|
|
@ -790,12 +790,13 @@ static void message_status(LinphoneChatMessage* msg,LinphoneChatMessageState sta
|
|||
[UIView setAnimationCurve:curve];
|
||||
[UIView setAnimationBeginsFromCurrentState:TRUE];
|
||||
|
||||
if(UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
|
||||
if(([[UIDevice currentDevice].systemVersion floatValue] < 8) &&
|
||||
UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
|
||||
int width = endFrame.size.height;
|
||||
endFrame.size.height = endFrame.size.width;
|
||||
endFrame.size.width = width;
|
||||
}
|
||||
|
||||
|
||||
// Resize chat view
|
||||
{
|
||||
CGRect viewFrame = [[self view] frame];
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@
|
|||
- (void)setFullScreen:(BOOL) enabled;
|
||||
- (void)setStateBarHidden:(BOOL) hidden;
|
||||
- (void)setToolBarHidden:(BOOL) hidden;
|
||||
- (BOOL)currentViewSupportsLandscape;
|
||||
- (UIViewController *)getCachedController:(NSString*)name;
|
||||
- (UIViewController *)getCurrentViewController;
|
||||
- (UIInterfaceOrientation)currentOrientation;
|
||||
|
|
|
|||
|
|
@ -165,13 +165,31 @@
|
|||
|
||||
#pragma mark - ViewController Functions
|
||||
|
||||
- (void)updateViewsFramesAccordingToLaunchOrientation {
|
||||
CGRect frame = [self.view frame]; // this view has the correct size at launch (1024/768 for iPad, 320*{568,480} for iPhone)
|
||||
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
|
||||
BOOL portrait = UIInterfaceOrientationIsPortrait(orientation);
|
||||
CGRect oppositeFrame = frame;
|
||||
oppositeFrame.size.height = frame.size.width;
|
||||
oppositeFrame.size.width = frame.size.height;
|
||||
|
||||
// if we start in portrait, the landscape view must get the opposite height and width
|
||||
if( portrait || [[UIDevice currentDevice].systemName floatValue] < 8 ){
|
||||
Linphone_log(@"landscape get opposite: %@", NSStringFromCGSize(oppositeFrame.size));
|
||||
[landscapeView setFrame:oppositeFrame];
|
||||
} else {
|
||||
// if we start in landscape, the landscape view has to get the current size,
|
||||
// whereas the portrait has to get the opposite
|
||||
Linphone_log(@"landscape get frame: %@ and portrait gets opposite: %@", NSStringFromCGSize(frame.size), NSStringFromCGSize(oppositeFrame.size));
|
||||
[landscapeView setFrame:frame];
|
||||
[portraitView setFrame:oppositeFrame];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
/* Force landscape view to match portrait view */
|
||||
CGRect frame = [portraitView frame];
|
||||
int height = frame.size.width;
|
||||
frame.size.width = frame.size.height;
|
||||
frame.size.height = height;
|
||||
[landscapeView setFrame:frame];
|
||||
/* Force landscape view to match portrait view, because portrait view inherits
|
||||
the device screen size at load */
|
||||
[self updateViewsFramesAccordingToLaunchOrientation];
|
||||
[super viewDidLoad];
|
||||
}
|
||||
|
||||
|
|
@ -215,6 +233,8 @@
|
|||
[self.stateBarViewController viewDidDisappear:animated];
|
||||
}
|
||||
|
||||
#pragma mark - Rotation messages
|
||||
|
||||
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
|
||||
currentOrientation = toInterfaceOrientation;
|
||||
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
|
||||
|
|
@ -224,7 +244,7 @@
|
|||
}
|
||||
|
||||
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
|
||||
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
|
||||
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration]; // Will invoke TPMultiLayout
|
||||
[self.contentViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
|
||||
[self.tabBarViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
|
||||
[self.stateBarViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
|
||||
|
|
@ -265,58 +285,27 @@
|
|||
*/
|
||||
+ (void)setOrientation:(UIInterfaceOrientation)orientation animated:(BOOL)animated {
|
||||
UIView *firstResponder = nil;
|
||||
for(UIWindow *window in [[UIApplication sharedApplication] windows]) {
|
||||
if([NSStringFromClass(window.class) isEqualToString:@"UITextEffectsWindow"] ||
|
||||
[NSStringFromClass(window.class) isEqualToString:@"_UIAlertOverlayWindow"] ) {
|
||||
continue;
|
||||
}
|
||||
UIView *view = window;
|
||||
UIViewController *controller = nil;
|
||||
CGRect frame = [view frame];
|
||||
if([window isKindOfClass:[UILinphoneWindow class]]) {
|
||||
controller = window.rootViewController;
|
||||
view = controller.view;
|
||||
}
|
||||
UIInterfaceOrientation oldOrientation = controller.interfaceOrientation;
|
||||
|
||||
NSTimeInterval animationDuration = 0.0;
|
||||
if(animated) {
|
||||
animationDuration = 0.3f;
|
||||
}
|
||||
[controller willRotateToInterfaceOrientation:orientation duration:animationDuration];
|
||||
if(animated) {
|
||||
[UIView beginAnimations:nil context:nil];
|
||||
[UIView setAnimationDuration:animationDuration];
|
||||
}
|
||||
switch (orientation) {
|
||||
case UIInterfaceOrientationPortrait:
|
||||
[view setTransform: CGAffineTransformMakeRotation(0)];
|
||||
break;
|
||||
case UIInterfaceOrientationPortraitUpsideDown:
|
||||
[view setTransform: CGAffineTransformMakeRotation(M_PI)];
|
||||
break;
|
||||
case UIInterfaceOrientationLandscapeLeft:
|
||||
[view setTransform: CGAffineTransformMakeRotation(-M_PI / 2)];
|
||||
break;
|
||||
case UIInterfaceOrientationLandscapeRight:
|
||||
[view setTransform: CGAffineTransformMakeRotation(M_PI / 2)];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if([window isKindOfClass:[UILinphoneWindow class]]) {
|
||||
[view setFrame:frame];
|
||||
}
|
||||
[controller willAnimateRotationToInterfaceOrientation:orientation duration:animationDuration];
|
||||
if(animated) {
|
||||
[UIView commitAnimations];
|
||||
}
|
||||
[controller didRotateFromInterfaceOrientation:oldOrientation];
|
||||
if(firstResponder == nil) {
|
||||
firstResponder = [UICompositeViewController findFirstResponder:view];
|
||||
}
|
||||
|
||||
UIViewController *controller = nil;
|
||||
|
||||
controller = [[UIApplication sharedApplication] keyWindow].rootViewController;
|
||||
CGRect frame = [[UIScreen mainScreen] bounds];
|
||||
UIInterfaceOrientation oldOrientation = controller.interfaceOrientation;
|
||||
|
||||
NSTimeInterval animationDuration = animated? 0.3f : 0.0;
|
||||
|
||||
[controller willRotateToInterfaceOrientation:orientation duration:animationDuration];
|
||||
[controller willAnimateRotationToInterfaceOrientation:orientation duration:animationDuration];
|
||||
[controller didRotateFromInterfaceOrientation:oldOrientation];
|
||||
[UIView animateWithDuration:animationDuration animations:^{
|
||||
[controller.view setFrame:frame];
|
||||
}];
|
||||
|
||||
if(firstResponder == nil) {
|
||||
firstResponder = [UICompositeViewController findFirstResponder:controller.view];
|
||||
}
|
||||
[[UIApplication sharedApplication] setStatusBarOrientation:orientation animated:animated];
|
||||
|
||||
// [[UIApplication sharedApplication] setStatusBarOrientation:orientation animated:animated];
|
||||
if(firstResponder) {
|
||||
[firstResponder resignFirstResponder];
|
||||
[firstResponder becomeFirstResponder];
|
||||
|
|
@ -499,8 +488,8 @@
|
|||
|
||||
UIViewController *newContentViewController = [self getCachedController:description.content];
|
||||
UIViewController *newStateBarViewController = [self getCachedController:description.stateBar];
|
||||
UIViewController *newTabBarViewController = [self getCachedController:description.tabBar];
|
||||
|
||||
UIViewController *newTabBarViewController = [self getCachedController:description.tabBar];
|
||||
|
||||
[UICompositeViewController removeSubView: oldContentViewController];
|
||||
if(oldTabBarViewController != nil && oldTabBarViewController != newTabBarViewController) {
|
||||
[UICompositeViewController removeSubView:oldTabBarViewController];
|
||||
|
|
@ -508,7 +497,7 @@
|
|||
if(oldStateBarViewController != nil && oldStateBarViewController != newStateBarViewController) {
|
||||
[UICompositeViewController removeSubView:oldStateBarViewController];
|
||||
}
|
||||
|
||||
|
||||
self.stateBarViewController = newStateBarViewController;
|
||||
self.contentViewController = newContentViewController;
|
||||
self.tabBarViewController = newTabBarViewController;
|
||||
|
|
@ -517,6 +506,11 @@
|
|||
UIInterfaceOrientation correctOrientation = [self getCorrectInterfaceOrientation:[[UIDevice currentDevice] orientation]];
|
||||
if(currentOrientation != correctOrientation) {
|
||||
[UICompositeViewController setOrientation:correctOrientation animated:currentOrientation!=UIDeviceOrientationUnknown];
|
||||
if( UIInterfaceOrientationIsLandscape(correctOrientation) ){
|
||||
[self.contentViewController willAnimateRotationToInterfaceOrientation:correctOrientation duration:0];
|
||||
[self.tabBarViewController willAnimateRotationToInterfaceOrientation:correctOrientation duration:0];
|
||||
[self.stateBarViewController willAnimateRotationToInterfaceOrientation:correctOrientation duration:0];
|
||||
}
|
||||
} else {
|
||||
if(oldContentViewController != newContentViewController) {
|
||||
UIInterfaceOrientation oldOrientation = self.contentViewController.interfaceOrientation;
|
||||
|
|
@ -536,7 +530,7 @@
|
|||
[self.stateBarViewController willAnimateRotationToInterfaceOrientation:correctOrientation duration:0];
|
||||
[self.stateBarViewController didRotateFromInterfaceOrientation:oldOrientation];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
oldViewDescription = (currentViewDescription != nil)? [currentViewDescription copy]: nil;
|
||||
}
|
||||
|
|
@ -681,4 +675,8 @@
|
|||
return [[self.contentViewController retain] autorelease];
|
||||
}
|
||||
|
||||
- (BOOL)currentViewSupportsLandscape {
|
||||
return currentViewDescription ? currentViewDescription.landscapeMode : FALSE;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<color key="backgroundColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
</view>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="mainViewController" destination="emC-P9-oZj" id="goX-7a-wOn"/>
|
||||
|
|
|
|||
|
|
@ -917,7 +917,8 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
[UIView setAnimationCurve:curve];
|
||||
[UIView setAnimationBeginsFromCurrentState:TRUE];
|
||||
|
||||
if(UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
|
||||
if(([[UIDevice currentDevice].systemVersion floatValue] < 8) &&
|
||||
UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
|
||||
int width = endFrame.size.height;
|
||||
endFrame.size.height = endFrame.size.width;
|
||||
endFrame.size.width = width;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue