IOS 横屏 打开相册 问题

IOS 竖屏 打开相册 是完全没问题的,也没有什么警告

UIImagePickerController

用于 相机 相册 照片 iOS API中明确指出只适合竖屏状态下打开

忙了2天终于找到问题所在

在 例子中添加这么两句就可以较好解决 但还是有警告 

定义

@interface IOSAlbumCameraController :UIViewController<UIImagePickerControllerDelegate,UINavigationControllerDelegate>

- (BOOL) shouldAutorotate;

- (NSUInteger)supportedInterfaceOrientations;

@end


实现 添加到具体代码里

- (BOOL) shouldAutorotate {

    returnYES;

}


- (NSUInteger)supportedInterfaceOrientations {

    returnUIInterfaceOrientationMaskAll;

}

虽然还有警告但至少过了 可以横屏出了。



这里要注意的一点是 Unity的 旋转 要设置为自由旋转然后全选 四种

然后 修改这里 就可以了,暂时没时间看为什么 先记下来 有时间再看

- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
{
	// UIInterfaceOrientationMaskAll
	// it is the safest way of doing it:
	// - GameCenter and some other services might have portrait-only variant
	//     and will throw exception if portrait is not supported here
	// - When you change allowed orientations if you end up forbidding current one
	//     exception will be thrown
	// Anyway this is intersected with values provided from UIViewController, so we are good
	//return   (1 << UIInterfaceOrientationPortrait) | (1 << UIInterfaceOrientationPortraitUpsideDown)
	//	   | (1 << UIInterfaceOrientationLandscapeRight) | (1 << UIInterfaceOrientationLandscapeLeft);
     return UIInterfaceOrientationMaskLandscape;
}

还有 有个地方最好也要横屏出现 要不 每次实现窗口就会 旋转能看到不适很好
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    picker.sourceType = type;
    picker.allowsEditing = flag;
    picker.modalPresentationStyle = UIModalPresentationCurrentContext;

就是最后一句 要横屏。






  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值