Xcode UIImagePickerController在启动时崩溃
我向用户展示了一个viewcontroller,其中的视图显示了录制视频的UI按钮。当用户按下按钮时,我的应用程序崩溃,出现以下错误: 由于未捕获的异常“UIApplicationInvalidInterfaceOrientation”而终止应用程序,原因:“preferredInterfaceOrientationForPresentation必须返回支持的接口方向!” 我的应用程序只支持纵向,info.plist文件可以正确反映方向。我在Ray Wenderlich的网站上找到的另一个应用程序中使用了相同的代码,效果非常好。.h和.m文件的代码如下所示。任何帮助都将不胜感激 .hXcode UIImagePickerController在启动时崩溃,xcode,uiimagepickercontroller,video-capture,ios6.1,Xcode,Uiimagepickercontroller,Video Capture,Ios6.1,我向用户展示了一个viewcontroller,其中的视图显示了录制视频的UI按钮。当用户按下按钮时,我的应用程序崩溃,出现以下错误: 由于未捕获的异常“UIApplicationInvalidInterfaceOrientation”而终止应用程序,原因:“preferredInterfaceOrientationForPresentation必须返回支持的接口方向!” 我的应用程序只支持纵向,info.plist文件可以正确反映方向。我在Ray Wenderlich的网站上找到的另一个应用程
#import <MediaPlayer/MediaPlayer.h>
#import <MobileCoreServices/UTCoreTypes.h>
#import <AssetsLibrary/AssetsLibrary.h>
@interface RecordSwingViewController: UIViewController
-(BOOL)startCameraControllerFromViewController:(UIViewController*)controller
usingDelegate:(id )delegate;
-(void)video:(NSString *)videoPath didFinishSavingWithError:(NSError *)error contextInfo:(void*)contextInfo;
@property (weak, nonatomic) IBOutlet UIButton *record;
- (IBAction)recordSwing:(id)sender;
@end
您已经为自动旋转实现了bool,但没有指定它是否不自动旋转,还应该做什么。尝试以下自动旋转后的方法
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}
请从上面的方法中删除任何不需要的遮罩,然后查看这是否适合您。您已经实现了用于自动旋转的bool,但没有指定它是否不自动旋转,还应该执行哪些操作。尝试以下自动旋转后的方法
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}
请从上述方法中移除任何您不需要的遮罩,看看这是否适合您。好的,最后是答案。
基本上,我需要向UIImagePickerController添加一个类别。我尝试了很多其他的修复方法,但都奏效了。好的,最后是答案。
基本上,我需要向UIImagePickerController添加一个类别。我尝试了许多其他修复,但都成功了。感谢您的回答,不幸的是,我仍然收到添加代码时尝试的错误,并且所有错误都被注释掉了,没有任何更改-(BOOL)应该自动旋转{return NO;}-(NSUInteger)supportedInterfaceOrientationMaskPortrait;}感谢您的回答,不幸的是,我仍然得到了添加代码时尝试的错误,所有错误都被注释掉了,没有任何更改-(BOOL)应该自动旋转{return NO;}-(NSUInteger)支持的接口方向{return UIInterfaceOrientationMaskPortrait;}