在 iPhone 4S 上从 ALAsset 设置 fullScreenImage 比在 iPhone 4 上慢
我正在使用 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;
}
I'm retrieving photos from the user camera roll with ALAsset, to present them on a scrollview, like the photo app. The following function works smoothly on iPhone 4 (iOS 4.3.3) and not on iPhone 4S (iOS 5.0.0): it block on every change of page for about 0.5 seconds. Where can be the problem?
Thank you in advance!
- (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;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论