Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 17 additions & 20 deletions cocos/platform/ios/CCEAGLView-ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ - (void)onUIKeyboardNotification:(NSNotification *)notif;
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;
Expand All @@ -744,15 +744,9 @@ - (void)onUIKeyboardNotification:(NSNotification *)notif;
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;
Expand All @@ -763,15 +757,9 @@ - (void)onUIKeyboardNotification:(NSNotification *)notif;
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;
Expand Down Expand Up @@ -850,6 +838,15 @@ - (void)onUIKeyboardNotification:(NSNotification *)notif;
}
}

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];
Expand All @@ -869,7 +866,7 @@ -(void) doAnimationWhenKeyboardMoveWithDuration:(float)duration distance:(float)
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);
Expand Down