Reputation: 4905
I have four imageview in sequence on a screen setting with custom background images. When user touches an imageview (for ex: user touches second imageview), can i get touch notification with which imageview is touched? I have array of imageview already and placed, and i have to implement touch event and under that identify which imageview is selected.
I want help from some one who can have suggestions to develop this, please suggest me?
thanks.
Upvotes: 0
Views: 4412
Reputation: 24466
Using UIButtons as replacements for your UIImageViews is a great idea that Morion mentioned as you can just drag a connection from each button to an outlet in your view controller and handle the action. You can set the background image on the buttons as you are doing currently with the UIImageViews. Set your button type to custom and you'll be good to go.
If, however, you are set on using UIImageView, you will have to subclass UIImageView and override the touch methods you want to intercept. For example:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
// Call super to make sure you don't lose any functionality
[super touchesBegan:touches withEvent:event];
// Perform the actions you want to perform with the tap.
}
Upvotes: 1
Reputation: 10860
you can use custom buttons instead of UIImages. so it will be easy to find which of them was pressed.
Upvotes: 0