2010-08-16 88 views
0

縮放圖像我怎樣才能得到,當它由用戶縮放圖像大小, 我寫下這些在我的項目:獲取圖像大小時,由用戶

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView 
{ 
return imageView; 
} 
-(void) didLoad{ 
UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage  imageNamed:@"image.jpg"]]; 
self.imageView = tempImageView; 
[tempImageView release]; 

scrollMapView.contentSize = CGSizeMake(imageView.frame.size.width, imageView.frame.size.height); 
scrollMapView.maximumZoomScale = 4.0; 
scrollMapView.minimumZoomScale = 0.75; 
scrollMapView.clipsToBounds = YES; 
scrollMapView.delegate = self; 
[scrollMapView addSubview:imageView]; 
} 

我只是想知道圖像大小時,放大.. 謝謝。

+0

你的意思是,如果一個200x400的圖像以2倍顯示,你想要的東西,返回400x800? – Vegar 2010-08-17 07:04:33

+0

是啊,類似的東西..順便說一句,我已經得到了.. thnx兄弟.. :) – 2011-06-20 03:15:17

回答

3

也許你可以這樣做:

newZoomedWidth = scrollView.zoomScale * imageView.frame.size.width 
1

我可能是錯誤的(我不是iPhone開發者),但我不認爲圖像本身得到放大;它只是縮放圖像視圖的滾動視圖的顯示。所以,它只是滾動視圖的一個屬性發生了變化;圖像保持不變。

這意味着你應該能夠只需get the image view's imageask that for its size

如果您想要圖像的縮放大小而不是其原始大小,請獲取其原始大小並將兩個維度乘以the scroll view's zoom scale