iPhone 사진 앱 (기본 iPhone 앱)을 구현하고 싶습니다. 큰 이미지 (2500 * 3700)를로드하려고 할 때 어려움에 직면했습니다. 한 이미지에서 다른 이미지로 스크롤하고 싶을 때 나는 말더듬 같은 것을 본다. 그것은 방법을 표시 한 애플 사이트에서 내가 ImageScrollView을 사용하여 이미지를 표시하려면 : 내 앱 ImageScrollView.m큰 이미지의 UIImageView. 문제
- (void)displayImage:(UIImage *)image
{
// clear the previous imageView
[imageView removeFromSuperview];
[imageView release];
imageView = nil;
// reset our zoomScale to 1.0 before doing any further calculations
self.zoomScale = 1.0;
self.imageView = [[[UIImageView alloc] initWithImage:image] autorelease];
[self addSubview:imageView];
self.contentSize = [image size];
[self setMaxMinZoomScalesForCurrentBounds];
self.zoomScale = self.minimumZoomScale;
}
- (void)setMaxMinZoomScalesForCurrentBounds
{
CGSize boundsSize = self.bounds.size;
CGSize imageSize = imageView.bounds.size;
// calculate min/max zoomscale
CGFloat xScale = boundsSize.width/imageSize.width; // the scale needed to perfectly fit the image width-wise
CGFloat yScale = boundsSize.height/imageSize.height; // the scale needed to perfectly fit the image height-wise
CGFloat minScale = MIN(xScale, yScale); // use minimum of these to allow the image to become fully visible
// on high resolution screens we have double the pixel density, so we will be seeing every pixel if we limit the
// maximum zoom scale to 0.5.
CGFloat maxScale = 1.0/[[UIScreen mainScreen] scale];
// don't let minScale exceed maxScale. (If the image is smaller than the screen, we don't want to force it to be zoomed.)
if (minScale > maxScale) {
minScale = maxScale;
}
self.maximumZoomScale = maxScale;
self.minimumZoomScale = minScale;
}
을 내가 먼저 보여, 600 개 * 600 이미지를 가지고있다. 사용자가 다음 이미지로 스크롤하면 600 * 600 이미지 만 보입니다. 그런 배경에서 I로드 * 3600 (3600) 화상
I 참조[operationQueue addOperationWithBlock:^{
UIImage *image = [self getProperBIGImage];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
ImageScrollView *scroll = [self getCurrentScroll];
[scroll displayImage:newImage];
}];
}];
, 화상의 차원은 * 3600 3600이며, I는 640 * 960 화면에 화상을 표시 할 때, 아이폰 메인 큐 시간 1 초를 낭비한다는 이미지의 크기를 조절해야하므로이 1 초 동안 다음 이미지로 스크롤 할 수 없습니다.
이미지를 확대/축소 할 수 있어야하므로 이미지를 확대하고 싶습니다. 나는이 방법을 사용하려고 시도했지만 도움이되지 않았습니다.
1) 배경에있는 UIImageView에서 이미지 스케일링을 제공합니다 (그러나 나는
2)를 사용하는) UI는 메인 스레드에서 변경되어야한다는 것을 알고있다 - (:
나는 몇 가지 가능한 솔루션을 참조 UIView *) viewForZoomingInScrollView : (UIScrollView *) 처음에는 600 * 600 이미지 만 표시하고 사용자가 확대/축소하려고하면 큰 이미지를로드하기 위해 scrollViewCalled (UIImageView를 초기화하려고하면 1 초 느슨해집니다. bigImage를 사용하고이 UIImageView를 반환하면 스크롤 동작이 잘못된 (잘못된 설명이있는) 잘못된 스크롤 뷰와 다른 배율로 다른 뷰를 반환하려고 할 때 볼 수 있기 때문에 구현할 수도 없습니다.
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollViewCalled
{
if (!zooming)
{
ImageScrollView *scroll = (ImageScrollView *)scrollViewCalled;
UIImageView *imageView = (UIImageView *)[scroll imageView];
return imageView;
}
else
{
UIImageView *bigImageView = [self getBigImageView];
return bigImageView;
}
}