IOS上的UIApplicationInvalidInterfaceOrientation crash

  最近在游戏中加入一个打开本地相册选择图片上传的功能,在ios上使用了UiImagePicker,去显示相册,可是在iphone上运行的时候,会crash,并给出这样的信息:ios

'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES.
app


 在网上找了找缘由,出现问题的缘由是,UiImagePicker使用的uiviewcontroller只支持Portrait选择,而咱们的游戏是一个landscape的游戏,在Appdelegate的- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window中也只支持了landscape。iview

 

一个viewcontroller支持的朝向在这个controller的iphone

- (NSUInteger)supportedInterfaceOrientations中定义。
 
supportedInterfaceOrientations是只支持portrait的,可是咱们的app的supportedInterfaceOrientationsForWindow没有portrait,就crash,在这里的解决办法就是将supportedInterfaceOrientationsForWindow中返回UIInterfaceOrientationMaskAll,以支持全部的朝向
当一个viewcontroller启动时,它会根据当前的手机朝向和他的shouldAutorotateToInterfaceOrientation接口来肯定这个view的旋转,肯定好后,还要看这个app的supportedInterfaceOrientationsForWindow中是否有它要作的朝向,若是没有就会crash。 在咱们这个例子中,相册的view中的
相关文章
相关标签/搜索