2016-08-18 39 views
1

我尝试了几种不同的方法来呈现横向应用程序中的横向UIImagePickerController(不是我自己选择的)我正在处理的。如何解决横向UIImagePickerController中的画廊滚动口吃?

当我(成功)以横向格式呈现画廊并滚动浏览图片时,会出现真正可怕的口吃!

目前的技术我使用的是这样的:

- (void)presentImagePickerController:(UIImagePickerControllerSourceType)sourceType { 
    UIImagePickerController *picker = [[UIImagePickerController alloc] init]; 

    if (isDeviceIPad) { 
     picker.modalPresentationStyle = UIModalPresentationFormSheet; 
     picker.preferredContentSize = [UIScreen mainScreen].bounds.size; 
    } 

    picker.sourceType = sourceType; 
    picker.delegate = self; 
    picker.allowsEditing = YES; 
    [self presentViewController:picker 
         animated:YES 
        completion:nil]; 
} 

我不能与使用专用接口,因为应用程序必须通过App Store的审查解决方案去。我不想使用第三方库,因为我的老板反对这个想法。

我的iPad是运行iOS 8.1的第三代机型MD334LL/A。

+0

iPad 3有性能问题。它的硬件对于视网膜显示来说太慢了。 –

+0

画廊在纵向滚动时,画廊非常流畅地在我的iPad上滚动。 –

+0

但是它具有较少的图像空间。 –

回答

0

从UIImagePickerController类参考这里找到:https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImagePickerController_Class/index.html

在iPad上,呈现的图像拾取正确的方式取决于它的源类型,总结此表:

相机:使用全屏

图片库:一定要用酥料饼

保存的照片相册:一定要用酥料饼

答案:由于我想呈现保存的照片相册,我需要通过使用弹出窗口来呈现选择器。

- (void)presentImagePickerController:(UIImagePickerControllerSourceType)sourceType { 
    UIImagePickerController *picker = [[UIImagePickerController alloc] init]; 

    picker.sourceType = sourceType; 
    picker.delegate = self; 
    picker.allowsEditing = YES; 

    if (isDeviceIPad() && sourceType == UIImagePickerControllerSourceTypeSavedPhotosAlbum) { 
     picker.modalPresentationStyle = UIModalPresentationPopover; 

     UIPopoverPresentationController *presentationController = picker.popoverPresentationController; 
     presentationController.permittedArrowDirections = UIPopoverArrowDirectionAny; 
     presentationController.sourceView = self.presentPickerButton; 
     presentationController.sourceRect = self.presentPickerButton.bounds; 
    } 

    [self presentViewController:picker 
         animated:YES 
        completion:nil]; 
}