我在我的按钮操作函数中使用了以下代码:
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];上崩溃了
有人能帮我指出我做错了什么吗?
发布于 2012-12-28 15:05:37
这是针对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;
}而且它起作用了。
https://stackoverflow.com/questions/14056243
复制相似问题