1

タグ値を使用して、異なる画像で 5 つの画像ビューを作成します。ここで、現在タッチされているイメージビューを touches Begin メソッドで特定したいと考えています。

誰でもガイドを手伝ってください。

4

2 に答える 2

1

これを試して:-

お問い合わせで始めた方法

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[touches allTouches]anyObject]; // Picks up the touch
NSLog(@"touched view%@",[touch view]);
UIView *view=[touch view];//here you can find the view which is touched and after that you can compare it with your image views like
if(view==(UIImageView *)[self.view viewWithTag:1])
{
//first image view touched
}
}
//you can proceed in this way.

お役に立てれば!

于 2012-08-30T07:04:32.587 に答える
0

これを試して:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
  UITouch *touch = [[touches allTouches]anyObject]; // Picks up the touch
  UIImageView *view=(UIImageView *)[touch view];//here you can find the view which is touched and after that you can compare it with your image views like
 if(view){

      if([view tag] == 0)
      {
          //UIImageView with tag 0 touched
      }
      else if([view tag] == 1)
      {
          //UIImageView with tag 1 touched
      }
      else if([view tag] == 2)
      {
          //UIImageView with tag 2 touched
      }
      else if([view tag] == 3)
      {
          //UIImageView with tag 3 touched
      }
      else if([view tag] == 4)
      {
          //UIImageView with tag 4 touched
      }
    }
  }
}
于 2012-08-30T07:14:00.333 に答える