IOS 横屏 打开相册 问题

    xiaoxiao2021-04-12  31

    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; 就是最后一句 要横屏。

    转载请注明原文地址: https://ju.6miu.com/read-667160.html

    最新回复(0)