简体   繁体   English

相册在iPad2中崩溃

[英]Photo album crashes in iPad2

I am presenting photo album and camera from a UIButton from a UIPopOverController. 我正在通过UIPopOverController的UIButton呈现相册和相机。 Both works fine when I present it in iPad1 running on iOS 5.1 . 当我在运行iOS 5.1 iPad1展示它时,两者都可以正常工作。

When I do the same thing in iPad2 running on iOS 6.0 , the camera works fine but the photo album crashes as in the below image. 当我在iOS 6.0上运行的iPad2执行相同操作时,相机工作正常,但相册崩溃,如下图所示。 Also note than the app is a landscape app. 还请注意,该应用程序是横向应用程序。

在此处输入图片说明

The code Im using is 我使用的代码是

 //imgPicker.contentSizeForViewInPopover = CGSizeMake(320, 500);
self.popOver = [[UIPopoverController alloc] initWithContentViewController:picker];
popOver.delegate = self;
[self.popOver presentPopoverFromRect:importFromPhotosBtn.frame
                              inView:importFromPhotosBtn
            permittedArrowDirections:UIPopoverArrowDirectionAny
                            animated:YES];

Please someone point me out what went wrong. 请有人指出我出了什么问题。 Im struck up with this for more than half a day. 我对此感到震惊超过半天。 Any timely help is much more appreciated. 任何及时的帮助,我们将不胜感激。

The UIImagePicker is supported on the portrait mode. 纵向模式支持UIImagePicker。 Your application supports only landscape mode, that causes the issue. 您的应用程序仅支持横向模式,这会导致问题。

Solution: 解:

  1. Subclass UIImagePicker class 子类UIImagePicker类
  2. Implement shouldAutorotate in the subclass 在子类中实现shouldAutorotate

      - (BOOL)shouldAutorotate { return NO; } 
  3. Use this subclassed UIImagePicker class for creating picker instead of UIImagePicker 使用此子类化的UIImagePicker类来创建选择器,而不是使用UIImagePicker

Thanks for @Midhum MP's clue, the problem actually was the frame from which I presented the popOver. 感谢@Midhum MP的提示,问题实际上出在我提出popOver的框架上。

The popOver size is 320 x 500 but I was presenting it from the rect containing (221, 360) as the origin, So the size messed up (500 + 360 which is greater than the iPad ht in landscape(768)). popOver大小为320 x 500但我是从包含( popOver )作为原点的矩形中提出的,因此大小混乱了(500 + 360,大于横向中的iPad ht(768))。

But not sure why it runs in iPad1(iOS 5.1) and not in iPad2 (iOS 6)! 但不确定为什么要在iPad1(iOS 5.1)中运行而不在iPad2(iOS 6)中运行!

So, I just changed the presenting rect (such that it won't've such mess-ups) which works fine now. 因此,我只是更改了演示矩形(这样就不会出现混乱)了,现在可以正常工作了。 It fixed the issue. 它解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM