UIImagePickerController和横向方向

时间:2013-03-05 06:47:34

标签: objective-c

我有一个UIImagePicker来点击图片并从照片库中选择一张图片。但我的应用程序必须只支持横向。照片库仅通过ImagePicker以纵向模式打开。我尝试将当前代码与ALAssets集成,但我不知道AlAssets库。我想使用图像Picker并使其在startMediaBrowserFromViewController:方法中调用ALAssets。以下是方法定义。请给我一个解决方案。

//pick an image from photo gallery  

- (BOOL) startMediaBrowserFromViewController: (UIViewController*) controller
                               usingDelegate: (id <UIImagePickerControllerDelegate,
                                               UINavigationControllerDelegate>) delegate {


    if (([UIImagePickerController isSourceTypeAvailable:
          UIImagePickerControllerSourceTypeSavedPhotosAlbum] == NO)
        || (delegate == nil)
        || (controller == nil))
        return NO;
    UIImagePickerController *mediaUI = [[UIImagePickerController alloc] init];
    mediaUI.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    //provides access to photo albums in the device.
    mediaUI.mediaTypes=[[[NSArray alloc]initWithObjects:(NSString*)kUTTypeImage,nil]autorelease];
    // Hides the controls for moving & scaling pictures.
    mediaUI.allowsEditing = NO;   
    mediaUI.delegate = delegate;
    [controller presentModalViewController: mediaUI animated: YES];
    return YES;
}

2 个答案:

答案 0 :(得分:0)

UIImagePickerController仅支持UIInterfaceOrientationPortrait方向,因此如果它是从横向视图控制器呈现的那么无关紧要,它将以纵向方式显示,即使在UIInterfaceOrientationPortraitUpsideDown

答案 1 :(得分:0)

我使用ELCImagePickerController来挑选图片。对我而言,与“普通”UIImagePickerController相比,它具有许多优势:

  • 您可以选择多张图片
  • 轻松支持横向模式
  • 易于定制
  • ...

我认为默认情况下它不支持横向定位,但我的工作非常简单。如果您需要帮助,请发表评论。

Gituhub

上查看