【问题标题】:Photogallary is appear in portrait mode even though iPhone is in landscape mode即使 iPhone 处于横向模式,照片集也会以纵向模式显示
【发布时间】:2012-08-02 06:40:17
【问题描述】:

大家好,我将设备设置为横向模式,在该模式下,当我按下“照片库”按钮时,图库以纵向模式打开,从图库中选择图片后,它将返回横向模式。当我在横向模式下工作时,我想以横向模式打开画廊。

我用这个代码打开相册

- (void)imagesFromGallery{
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
{
    if(!popover) 
    {
        popover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
    }

    [popover presentPopoverFromRect:CGRectMake(500, 620, 0, 0)
                             inView:self.view
           permittedArrowDirections:UIPopoverArrowDirectionUp 
                           animated:YES];
}
else 
{
    [self presentModalViewController:imagePicker animated:YES];
}   }

提前谢谢....

【问题讨论】:

  • 图片库始终以纵向模式打开,您无法将其更改为横向模式。除非您获取所有图像并制作自己的视图。这将是非常乏味的!
  • 在发布此类问题之前,请阅读文档。苹果提供所有参考是有原因的。与发布此问题相比,搜索文档所需的时间更少。 To quote the documentation "重要说明 UIImagePickerController 类仅支持纵向模式。"

标签: iphone ipad photo-gallery landscape-portrait


【解决方案1】:

而不是呈现它

 [self presentModalViewController:imagePicker animated:YES];

将imagePickerView添加到self.view并设置imagePicker的frame

[self.view addSubview:imagePicker.view];

希望它对你有用。!!

【讨论】:

    【解决方案2】:

    上面的答案很好用。但是一旦你加载了图片库,滚动视图和选择文件夹就成了问题。

    继承UIImagepicker 是正确的选择。只需创建一个 UIImagepicker 的子类并添加以下方法。

    -(NSUInteger)supportedInterfaceOrientations
    {
    
        return UIInterfaceOrientationMaskAll;
    }
    

    休息,照常分配这个视图控制器并呈现。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-28
      • 2014-07-01
      • 2014-03-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多