2016-08-18 36 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]; 
}