2

我正在使用 ALAsset 从用户相机胶卷中检索照片,以在滚动视图上呈现它们,就像照片应用程序一样。以下功能在 iPhone 4 (iOS 4.3.3) 上运行顺畅,而在 iPhone 4S (iOS 5.0.0) 上运行不畅:它会在每次页面更改时阻止大约 0.5 秒。问题可能出在哪里?

先感谢您!

- (UIView*) infinitePagingView:(InfinitePagingView*) infinitePagingView viewForPageIndex:(int) index
{
        ImageGalleryImageView *v = [[[ImageGalleryImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)] autorelease];
    v.autoresizesSubviews = YES;
    v.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin;

    if(photos.count<=index){
        return nil;
    }

    UIImage *theThumbnail = [UIImage imageWithCGImage:(CGImageRef) [[photos objectAtIndex:index] thumbnail]];
        [v setImageView: theThumbnail];
    dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
        ALAsset *object = [photos objectAtIndex:index];
        ALAssetRepresentation *representation = [object defaultRepresentation];
        float version = [[[UIDevice currentDevice] systemVersion] floatValue];

        UIImageOrientation theOrientation;
        if (version >= 5.0){
            theOrientation = UIImageOrientationUp;
        }
        else{
            theOrientation = (UIImageOrientation) [representation orientation];
        }

        UIImage *theFullImage = [[UIImage imageWithCGImage:(CGImageRef)[representation fullScreenImage] scale:1.0 orientation: theOrientation] autorelease];                            
        dispatch_sync(dispatch_get_main_queue(), ^{
            [v setImageView: theFullImage];
        });
    });

        return v;
}
4

0 回答 0