UIIMagePickerController在iPad ios 6.0上解散时崩溃

UIIMagePickerController在iPad ios 6.0上解散时崩溃,第1张

概述我使用iOS 6.0在iPad 4上工作. 我有一个带有以下init的ViewController(MyPickerController): - (id)init{    self = [super init];    if (self) {        _picker = [[UIImagePickerController alloc] init];        _picker.d 我使用iOS 6.0在iPad 4上工作.

我有一个带有以下init的VIEwController(MyPickerController):

- (ID)init{    self = [super init];    if (self) {        _picker = [[UIImagePickerController alloc] init];        _picker.delegate = self;        _picker.sourceType = UIImagePickerControllerSourceTypeCamera;        [self.vIEw addSubvIEw:_picker.vIEw];    }    return self;}

我实现了以下UIPickerControllerDelegate方法来dimiss MyPickerController:

- (voID)imagePickerControllerDIDCancel:(UIImagePickerController *)picker{    [self dismissVIEwControllerAnimated:YES completion:nil];}

好吧,我有另一个视图控制器在FormSheetStyle中显示模态,当我点击一个按钮时,我想用以下代码显示MyPickerController:

MyPickerController * pickerVC = [[MyPickerController alloc] init];[self presentVIEwController:pickerVC animated:YES completion:nil];

在我的AppDelegate中我有以下方法:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrIEntationsForWindow:(UIWindow *)window {        return (NSUInteger)[application supportedInterfaceOrIEntationsForWindow:window] | (1<<UIInterfaceOrIEntationPortrait);    }

当我点击UIIMagePicker的取消按钮进入MyPickerController时,应用程序崩溃并出现以下错误:

Terminating app due to uncaught exception 'UIApplicationInvalIDInterfaceOrIEntation',reason: 'preferredInterfaceOrIEntationForPresentation must return a supported interface orIEntation!

阅读stackoverflow上的相关问题,我还创建了以下UIImagePickerController类:

@implementation UIImagePickerController (NonRotating)- (BOol)shouldautorotate{    return NO;}- (UIInterfaceOrIEntation)preferredInterfaceOrIEntationForPresentation{    return UIInterfaceOrIEntationMaskPortrait;}- (NSUInteger)supportedInterfaceOrIEntations{    return UIInterfaceOrIEntationMaskPortrait;}@end

谢谢!

解决方法 试试这个..

如果您的视图控制器位于UINavigationController中,则应将此类别用于navigationcontroller:

@implementation UINavigationController (autorotate)- (NSUInteger)supportedInterfaceOrIEntations{      return UIInterfaceOrIEntationMaskAll;}- (UIInterfaceOrIEntation)preferredInterfaceOrIEntationForPresentation{      return UIInterfaceOrIEntationMaskPortrait;}@end
总结

以上是内存溢出为你收集整理的UIIMagePickerController在iPad ios 6.0上解散时崩溃全部内容,希望文章能够帮你解决UIIMagePickerController在iPad ios 6.0上解散时崩溃所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1082967.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存