mirror of https://github.com/axmolengine/axmol.git
fix ios8 EditBox orientation problem
This commit is contained in:
parent
efa1c86fc5
commit
34fbca9c50
|
@ -731,7 +731,7 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
|
|||
CGSize viewSize = self.frame.size;
|
||||
CGFloat tmp;
|
||||
|
||||
switch ([[UIApplication sharedApplication] statusBarOrientation])
|
||||
switch (getFixedOrientation([[UIApplication sharedApplication] statusBarOrientation]))
|
||||
{
|
||||
case UIInterfaceOrientationPortrait:
|
||||
begin.origin.y = viewSize.height - begin.origin.y - begin.size.height;
|
||||
|
@ -744,15 +744,9 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
|
|||
break;
|
||||
|
||||
case UIInterfaceOrientationLandscapeLeft:
|
||||
tmp = begin.size.width;
|
||||
begin.size.width = begin.size.height;
|
||||
begin.size.height = tmp;
|
||||
tmp = end.size.width;
|
||||
end.size.width = end.size.height;
|
||||
end.size.height = tmp;
|
||||
tmp = viewSize.width;
|
||||
viewSize.width = viewSize.height;
|
||||
viewSize.height = tmp;
|
||||
std::swap(begin.size.width, begin.size.height);
|
||||
std::swap(end.size.width, end.size.height);
|
||||
std::swap(viewSize.width, viewSize.height);
|
||||
|
||||
tmp = begin.origin.x;
|
||||
begin.origin.x = begin.origin.y;
|
||||
|
@ -763,15 +757,9 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
|
|||
break;
|
||||
|
||||
case UIInterfaceOrientationLandscapeRight:
|
||||
tmp = begin.size.width;
|
||||
begin.size.width = begin.size.height;
|
||||
begin.size.height = tmp;
|
||||
tmp = end.size.width;
|
||||
end.size.width = end.size.height;
|
||||
end.size.height = tmp;
|
||||
tmp = viewSize.width;
|
||||
viewSize.width = viewSize.height;
|
||||
viewSize.height = tmp;
|
||||
std::swap(begin.size.width, begin.size.height);
|
||||
std::swap(end.size.width, end.size.height);
|
||||
std::swap(viewSize.width, viewSize.height);
|
||||
|
||||
tmp = begin.origin.x;
|
||||
begin.origin.x = begin.origin.y;
|
||||
|
@ -850,6 +838,15 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
|
|||
}
|
||||
}
|
||||
|
||||
UIInterfaceOrientation getFixedOrientation(UIInterfaceOrientation statusBarOrientation)
|
||||
{
|
||||
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
|
||||
{
|
||||
statusBarOrientation = UIInterfaceOrientationPortrait;
|
||||
}
|
||||
return statusBarOrientation;
|
||||
}
|
||||
|
||||
-(void) doAnimationWhenKeyboardMoveWithDuration:(float)duration distance:(float)dis
|
||||
{
|
||||
[UIView beginAnimations:nil context:nullptr];
|
||||
|
@ -869,7 +866,7 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
|
|||
dis /= 2.0f;
|
||||
}
|
||||
|
||||
switch ([[UIApplication sharedApplication] statusBarOrientation])
|
||||
switch (getFixedOrientation([[UIApplication sharedApplication] statusBarOrientation]))
|
||||
{
|
||||
case UIInterfaceOrientationPortrait:
|
||||
self.frame = CGRectMake(originalRect_.origin.x, originalRect_.origin.y - dis, originalRect_.size.width, originalRect_.size.height);
|
||||
|
|
Loading…
Reference in New Issue