Quantcast
Channel: Cocos中文社区 - 最新主题
Viewing all articles
Browse latest Browse all 88774

iOS下横屏打开相册及返回问题总结

$
0
0

@xff8175 写道:

折腾了很久,总结一下,一个字累

1、设置打开相册为横屏
本身cocos是横屏的,但相册默认是竖屏的,所以要继承一下相册类自己实现横屏方法,把两个类引入到项目下即可
UIImagePickerController+LandScapeImagePicker.h

import

@interface UIImagePickerController (LandScapeImagePicker)
- (BOOL)shouldAutorotate;
- (NSUInteger)supportedInterfaceOrientations;

@end

UIImagePickerController+LandScapeImagePicker.mm

import "UIImagePickerController+LandScapeImagePicker.h"

@implementation UIImagePickerController (LandScapeImagePicker)
- (BOOL)shouldAutorotate {
return NO;
}

  • (NSUInteger)supportedInterfaceOrientations{
    // return UIInterfaceOrientationMaskLandscape;
    return UIInterfaceOrientationMaskLandscapeRight|UIInterfaceOrientationMaskLandscapeLeft;
    }

@end

2、解决cocos在相册横屏返回游戏后,界面某个时刻进入后台再恢复时界面变为竖屏的bug
由于RootViewController.mm的方法问题,导致后台游戏界面恢复回来后,进入竖屏状态,修改如下:
// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead
- (NSUInteger) supportedInterfaceOrientations{

ifdef _IPHONE6_0

//cocos默认值
// return UIInterfaceOrientationMaskAllButUpsideDown;
//横屏修改为以下值
return (UIInterfaceOrientationMaskLandscapeLeft |
UIInterfaceOrientationMaskLandscapeRight);
// return UIInterfaceOrientationMaskLandscape;

endif

}

帖子: 1

参与者: 1

阅读整个主题


Viewing all articles
Browse latest Browse all 88774

Trending Articles