2012-04-13 10 views
0

私はUIScrollView内にカラーマップを持っており、このマップのピクセルの色をサンプリングしようとしています。サンプルレチクルはスクロールビューの上に配置され、ユーザーはスクロールビューの内容をレチクルの下に移動します。iPhone iOSは、ズーム付きでUIScrollView内の位置を計算します

ユーザーはタップジェスチャーでレチクルを落とすことができますが、レチクルの下にビューを移動するオプションを追加したいと考えています。

私はyはズームビューの座標、Iは、Xを理解することができますどのようを見つけるためにしようとしているが、レチクル中です。これまでの論理は、特にズームイン/アウトが関係しているので、私を見逃しています。

-(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]; 

} 

ご了承ください。

答えて

1

あなたはUIViewの中にこれらの2つの方法で持って見てみたいことがあります。

- (CGPoint)convertPoint:(CGPoint)point toView:(UIView *)view; 
- (CGPoint)convertPoint:(CGPoint)point fromView:(UIView *)view; 
+0

どうもありがとう、これは働いていました! –

関連する問題