即使iPhone处于横向模式,Photogallary也会以纵向模式显示

时间:2012-08-02 06:40:18

标签: iphone ipad photo-gallery landscape-portrait

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

我用这段代码打开了照相馆

- (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];
}   }

提前致谢....

2 个答案:

答案 0 :(得分:2)

而不是呈现它

 [self presentModalViewController:imagePicker animated:YES];

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

[self.view addSubview:imagePicker.view];

希望它对你有用。!!

答案 1 :(得分:0)

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

UIImagepicker进行子类化是正确的选择。只需创建一个类UIImagepicker的子类,并添加以下方法。

-(NSUInteger)supportedInterfaceOrientations
{

    return UIInterfaceOrientationMaskAll;
}

休息,asusual分配这个viewcontroller并呈现。

相关问题