Iphone 无法打开UIImagePickerController

Iphone 无法打开UIImagePickerController,iphone,ios6,Iphone,Ios6,我在按钮操作功能中使用此代码: picker = [[UIImagePickerController alloc] init]; picker.delegate = self; picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; picker.allowsEditing = NO; picker.wantsFullScreenLayout = YES; [self presentViewController:pic

我在按钮操作功能中使用此代码:

picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.allowsEditing = NO;
picker.wantsFullScreenLayout = YES;
[self presentViewController:picker animated:YES completion:nil];
我也在执行委托<代码>UIImagePickerControllerDelegate

但它会在一个小时内崩溃
[自呈现视图控制器:选择器动画:是完成:无]


som one能帮我解决我做错了什么吗?

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

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    return UIInterfaceOrientationMaskAll;
else  /* iphone */
    return UIInterfaceOrientationMaskAllButUpsideDown;
}
在rootViewController中,我使用以下委托强制viewController处于横向模式并保持横向模式

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if(interfaceOrientation == UIInterfaceOrientationLandscapeRight)
    return YES;
else
    return NO;
}
- (BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeRight;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeRight;

}

它成功了。

你能发布堆栈跟踪吗?你可能遗漏了什么。如果尚未添加异常断点,请使用此[self-presentViewController:picker animated:YES];而不是[self-presentViewController:picker animated:YES completion:nil];你在ipad上使用这个吗?@prasad-我在使用iPod。如果你是,这个应用程序只支持横向。。那么这个链接可以解决你的问题