0

UIBezierPathクラスを使用してポリゴンを描画しています。

ポリゴンのリストがあります。ここで、任意のポリゴンをクリックすると、それがどのポリゴンであるかを検出したいと思います。で見ることができるのと同じ概念だと思いますUIMapView

4

1 に答える 1

0

これはどう?。

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{

    CGPoint p = [[touches anyObject] locationInView:self.view];

   // UIBezierPath *pathTodetect; Path of the shape that you want to detect. In a for loop you can check for all possible paths. 

    if(CGPathContainsPoint(pathTodetect.CGPath,nil, p, NO))
    {    

        NSLog(@"touched.");
        // the touch is inside the shape  
    }   

}
于 2012-02-13T08:43:41.823 に答える