解决横屏时调用系统相册崩溃的问题

之前开发中遇到的一个需求,要让APP强制横屏,但是在调用系统相册的时候会崩溃,原因是这样的

reason: 'Supported orientations has no common orientation with the application, and [PUUIAlbumListViewController shouldAutorotate] is returning YES'  

因为系通相册是默认支持竖屏,如果要横屏时打开系统相册,你要在AppDelegate.m中添加如下方法

-(UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window

{

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)//iPhone

        return UIInterfaceOrientationMaskAll;

    else//iPad

        return UIInterfaceOrientationMaskAllButUpsideDown;

}

然后为UIImagePickerController添加拓展

- (BOOL)shouldAutorotate{

    return NO;

}

- (NSUInteger)supportedInterfaceOrientations{

    return UIInterfaceOrientationMaskLandscape;

}

 

posted @ 2016-01-19 14:09  V清风  阅读(869)  评论(0编辑  收藏  举报