Настройка fullScreenImage от ALAsset медленнее на iPhone 4S, чем на iPhone 4 - PullRequest
2 голосов
/ 06 декабря 2011

Я извлекаю фотографии из пользовательской камеры с помощью 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;
}
...