mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-23 06:08:07 +00:00
Fix Dialer preview not angled correctly at first start if the device is rotated.
This commit is contained in:
parent
e7e583cd1d
commit
02ac9da3bd
2 changed files with 26 additions and 9 deletions
|
|
@ -28,6 +28,8 @@
|
|||
#import "UIDigitButton.h"
|
||||
|
||||
@interface DialerViewController : UIViewController <UITextFieldDelegate, UICompositeViewDelegate> {
|
||||
|
||||
CGFloat initialPreviewAngle;
|
||||
}
|
||||
|
||||
- (void)setAddress:(NSString*)address;
|
||||
|
|
|
|||
|
|
@ -135,6 +135,9 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
selector:@selector(coreUpdateEvent:)
|
||||
name:kLinphoneCoreUpdate
|
||||
object:nil];
|
||||
|
||||
initialPreviewAngle = [self orientationToAngleRad:self.interfaceOrientation];
|
||||
|
||||
// Update on show
|
||||
if([LinphoneManager isLcReady]) {
|
||||
LinphoneCore* lc = [LinphoneManager getLc];
|
||||
|
|
@ -211,26 +214,38 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
[super viewDidUnload];
|
||||
}
|
||||
|
||||
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
|
||||
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
|
||||
CGRect frame = [videoPreview frame];
|
||||
switch (toInterfaceOrientation) {
|
||||
- (CGFloat)orientationToAngleRad:(UIInterfaceOrientation)orientation {
|
||||
CGFloat angle=0;
|
||||
switch (orientation) {
|
||||
case UIInterfaceOrientationPortrait:
|
||||
[videoPreview setTransform: CGAffineTransformMakeRotation(0)];
|
||||
angle = 0;
|
||||
break;
|
||||
case UIInterfaceOrientationPortraitUpsideDown:
|
||||
[videoPreview setTransform: CGAffineTransformMakeRotation(M_PI)];
|
||||
angle = M_PI;
|
||||
break;
|
||||
case UIInterfaceOrientationLandscapeLeft:
|
||||
[videoPreview setTransform: CGAffineTransformMakeRotation(M_PI / 2)];
|
||||
angle = M_PI / 2;
|
||||
break;
|
||||
case UIInterfaceOrientationLandscapeRight:
|
||||
[videoPreview setTransform: CGAffineTransformMakeRotation(-M_PI / 2)];
|
||||
angle = -M_PI / 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
[videoPreview setFrame:frame];
|
||||
return angle;
|
||||
}
|
||||
|
||||
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
|
||||
UIInterfaceOrientation old = self.interfaceOrientation;
|
||||
CGFloat angle = 0;
|
||||
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
|
||||
|
||||
if( old != toInterfaceOrientation ){
|
||||
CGRect frame = [videoPreview frame];
|
||||
angle = [self orientationToAngleRad:toInterfaceOrientation] - initialPreviewAngle;
|
||||
[videoPreview setTransform: CGAffineTransformMakeRotation(angle)];
|
||||
[videoPreview setFrame:frame];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue