0
我在UIScrollView中有一個彩色地圖,並且試圖採樣該地圖的一個像素的顏色。樣本光罩位於滾動視圖上方,而用戶移動光罩下滾動視圖的內容。iPhone iOS通過縮放在UIScrollView中計算位置
用戶可以用水龍頭手勢放下十字線,但我想提供一個額外的選項來移動十字線下的視圖。
我試圖找出我如何理解放大視圖的x,y座標當前位於光罩下。迄今爲止,這個邏輯還沒有解決,特別是涉及到放大/縮小。
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGPoint mapLocation = [tapGestureRecognizer locationInView:self.surfaceMap];
NSLog(@"mapLocation (x,y) %.0f,%.0f",mapLocation.x,mapLocation.y);
NSLog(@"contentOffset (x,y) %.0f,%.0f",self.scrollView.contentOffset.x,self.scrollView.contentOffset.y);
//calculate where the marker is pointing to in the surface map while the scrollview is scrolling
int frameWidth = self.surfaceMap.frame.size.width;
int frameHeight = self.surfaceMap.frame.size.height;
//this is what I'm trying to calculate
CGPoint trueLocation = CGPointMake(self.scrollView.contentOffset.x+frameWidth-self.surfaceMap.frame.origin.x, self.scrollView.contentOffset.y-self.surfaceMap.frame.origin.y);
NSLog(@"trueLocation (x,y) %.0f,%.0f",trueLocation.x,trueLocation.y);
[self colorOfPixelAtPoint:trueLocation];
}
任何輸入讚賞!
非常感謝,這個工作! – 2012-04-13 17:55:38