关于cocos2d调用相册及摄像头问题

调用摄像头或相册需要用到UIImagePickerController这个类,
当然大家首先会想到以模态对话框的形式弹出相册,
但是注意这个类UIImagePickerController只在iphone平台下支持

presentModalViewController

的形式打开相册,且方向为竖屏,如果你开发横屏游戏可能会觉得不太好

关于ipad下,你需要用UIPopoverController来显示相册库,

这是你需要这样调用

 

UIImagePickerController *picker    = [[UIImagePickerController alloc]init];

    picker.delegate = self;

    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

    picker.wantsFullScreenLayout = YES;

    

    UIPopoverController * photoPop=[[UIPopoverController alloc] initWithContentViewController:picker];

    [photoPop presentPopoverFromRect:CGRectMake(inView.frame.size.width, inView.frame.size.height/2, 0, 0) inView:inView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

    [picker release];


这样就OK了,inView,关于这个对象,可以为openglView,也可以为加入到openglView中的任何继承自UIVIew的控件


调用摄像头与此类似


另外,为了适配ios6,你还需要加入以下委托方法

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {

    return UIInterfaceOrientationMaskAll;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值