0

こんにちは、ユーザーが画像の特定の部分、たとえば魚 (ひれ、尾) をクリックして xib の別のページに移動して、その部分の内容を表示できるアプリケーションを実装しようとしています。画像をクリックして有効にし、クリックするためのさまざまな部分を特定する方法を知っている人はいますか? 助けてください!どうもありがとう!

PS私は、画像をクリックして画像の座標を取得する方法を見つけました。if ステートメントでその座標を使用するにはどうすればよいですか? 例えば、

if (location = i) { このページに行く }

else if (location = a) { このページに行く }

4

2 に答える 2

1

これがあなたを助けるかもしれないように試してみてください、

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [[event allTouches] anyObject];
    CGPoint lastLocation = [touch locationInView: self.view];

 if (![[touch view] isKindOfClass:[UIImageView class]]) {
    if (lastLocation.x>103 & lastLocation.y<269) { //place your location points here

     // keep you condition based on image view and push the view here. 
   }
 }
}
于 2013-03-12T07:05:02.277 に答える