首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法打开UIImagePickerController

无法打开UIImagePickerController
EN

Stack Overflow用户
提问于 2012-12-27 22:27:59
回答 1查看 349关注 0票数 0

我在我的按钮操作函数中使用了以下代码:

代码语言:javascript
复制
picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.allowsEditing = NO;
picker.wantsFullScreenLayout = YES;
[self presentViewController:picker animated:YES completion:nil];

我也在实现这个委托。UIImagePickerControllerDelegate

但它在[self presentViewController:picker animated:YES completion:nil];上崩溃了

有人能帮我指出我做错了什么吗?

EN

回答 1

Stack Overflow用户

发布于 2012-12-28 15:05:37

这是针对IOS 6的。这些委托方法只在IOS 6中支持。我得到了我自己的问题的答案。我的应用程序是为景观模式开发的。因此imagePickerView无法显示自己,因为它的默认方向是横向。因此,我使我的应用程序支持横向和纵向模式。在应用程序委托中,我使用了方法,

代码语言:javascript
复制
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    return UIInterfaceOrientationMaskAll;
else  /* iphone */
    return UIInterfaceOrientationMaskAllButUpsideDown;
}

在rootViewController中,我使用了以下代理来强制viewController处于横向模式并保持横向模式。

代码语言:javascript
复制
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if(interfaceOrientation == UIInterfaceOrientationLandscapeRight)
    return YES;
else
    return NO;
}
- (BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeRight;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeRight;

}

而且它起作用了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14056243

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档