ios8.0以上 软键盘弹出,场景不能正常显示

请教:ios8.0以上 软键盘弹出,场景不能正常显示

在程序中调用editbox

正常:整个游戏场景能够垂直上移,输入完成后场景恢复正常位置(ios其他版本)

问题:整个场景向左上方偏移,输入完成后场景无法恢复正常(ios8.0)

:11::11::11::11::11:

你怎么这么开森,知道点什么 :12:

参考这个PR:https://github.com/cocos2d/cocos2d-x/pull/8149

有效请喵一声~

EGLView.mm 文件添加一个方法,判断一下ios版本,取方向的地方替换一下,
UIInterfaceOrientation getFixedOrientation(UIInterfaceOrientation statusBarOrientation)
{
if ( systemVersion] floatValue] >= 8.0)
{
statusBarOrientation = UIInterfaceOrientationPortrait;
}
return statusBarOrientation;
}

ios8适配问题
参考链接:
http://www.cocoachina.com/bbs/simple/?t230896.html
https://github.com/cocos2d/cocos2d-x/pull/8149/files

1赞

这个之前就已经看到了,按照3.3的版本进行了相关EAGLView文件的修改,场景上移还是存在问题,请问还有其他思路么
工程的cocos2dx版本是2.2的,目前只有按照最新版本对EAGLView进行过相应修改,请问是不是还需要对别处进行修改什么的:14:

忘了补充了,游戏横屏进入不会有问题(桌面应用图标是横屏)
竖屏进入就会出现场景往左上角移动不能恢复正常的情况(应用是横屏的)

结贴

总结:
问题具体描述:在ios8.1上cocos2d-x 3.0版本 弹出软件盘,ipad桌面锁竖屏,进入横屏的游戏,软键盘弹出glview显示区域被裁剪
修改方式:
CCEAGLView-ios.mm
-(void) doAnimationWhenKeyboardMoveWithDuration:(float)duration distance:(float)dis

switch (getFixedOrientation( statusBarOrientation]))
{
    case UIInterfaceOrientationPortrait:
        self.frame = CGRectMake(originalRect_.origin.x, originalRect_.origin.y - dis, originalRect_.size.width, originalRect_.size.height);
        break;
        
    case UIInterfaceOrientationPortraitUpsideDown:
        self.frame = CGRectMake(originalRect_.origin.x, originalRect_.origin.y + dis, originalRect_.size.width, originalRect_.size.height);
        break;
        
    case UIInterfaceOrientationLandscapeLeft:
        self.frame = CGRectMake(originalRect_.origin.x - dis, originalRect_.origin.y , originalRect_.size.width, originalRect_.size.height);
        break;
        
    case UIInterfaceOrientationLandscapeRight:
        self.frame = CGRectMake(originalRect_.origin.x + dis, originalRect_.origin.y , originalRect_.size.width, originalRect_.size.height);
        break;
        
    default:
        break;
}

修改成

switch (getFixedOrientation( statusBarOrientation]))
{
    case UIInterfaceOrientationPortrait:
        self.frame = CGRectMake(originalRect_.origin.x, originalRect_.origin.y - dis, self.frame.size.width, self.frame.size.height);
        break;
        
    case UIInterfaceOrientationPortraitUpsideDown:
        self.frame = CGRectMake(originalRect_.origin.x, originalRect_.origin.y + dis, self.frame.size.width, self.frame.size.height);
        break;
        
    case UIInterfaceOrientationLandscapeLeft:
        self.frame = CGRectMake(originalRect_.origin.x - dis, originalRect_.origin.y , self.frame.size.width, self.frame.size.height);
        break;
        
    case UIInterfaceOrientationLandscapeRight:
        self.frame = CGRectMake(originalRect_.origin.x + dis, originalRect_.origin.y , self.frame.size.width, self.frame.size.height);
        break;
        
    default:
        break;
}
3赞

解决了我的问题,真是感谢,查了两天的bug

mark…

解决了我的问题 ,太感谢了

特登录表示感谢!该方案解决了我遇到的问题:竖屏切横屏后,点输入框后界面跑左下角了,creator版本1.9.2(改造点老项目)