1
私はいくつかの画像を持つビューを持っています。私は選択したイメージを知りたい。画像を選択すると、別の画像を選択すると同じ方法になります。 すべての画像で、「touchesEnded:」メソッドが実行されます。 画像間には違いがありますか? ヘルプをいただければ幸いです。iPhoneのプログラミングでさまざまな画像と異なる点
私はいくつかの画像を持つビューを持っています。私は選択したイメージを知りたい。画像を選択すると、別の画像を選択すると同じ方法になります。 すべての画像で、「touchesEnded:」メソッドが実行されます。 画像間には違いがありますか? ヘルプをいただければ幸いです。iPhoneのプログラミングでさまざまな画像と異なる点
はthroughtにすべてのビューをenymerateしてください:
- (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event
{
// Enumerate through all the touch objects.
for (UITouch *touch in touches)
{
//Enumerate through all subviews
for (UIView *subView in [self.view subviews])
{
if (CGRectContainsPoint([subView frame], [touch locationInView:self.view]))
{
//Found touched view
/*Optional: you can set to each UIImageView tag and check it here
switch (subView.tag)
{
case 1:
break;
case 2:
break;
default:
break;
}
*/
}
}
}
}
ありがとうございました。あなたは問題を解決した – heziflash