views:

24

answers:

2

Hi everyone,

I have a little question. Maybe some of you know the app 'Munich my way'. It's an app where you can configurate your own shoe design. They show a shoe where you can tap on each part of the shoe (sole, shoelace and so on) to select it and then choosing a design for the part. My question is how to do that? I mean tapping on a specific part to select it. Does this work with masks?

A: 

You can definitely detect the coordinates of the point where the finger has touched the screen. Then you can make and use a map (two dimensional array mapping coordinates to the areas of interest) which can be used for detection - weather the touch was in the sole area, or on the laces.

Mapping array can contain, for instance, zeros for background pixels, 1's for sole, 2's for shoelace and so on.

I am pretty sure there is no simple way to do this, since you need to mark irregular areas.

Sergei Lost
A: 

If each part is an UIImageView you can create your own class that subclasses it and overrid the methods:

touchesBegan:withEvent:

touchesMoved:withEvent:

touchesEnded:withEvent: 

to get the touch input for each view and then send it to a controller to manage it with the information of which kind of piece has been touched.

But this suppose that the UIImageViews are not overlapping, in that case only the frontmost will receive the touch. In this case you can associate a vectorial representation to each piece of item and have just one UIView intercepting all touches that checks in which particular 'shape' the point of the touch falls. (You'd have to change coordinates from the frontmost view to the single UIImageViews)

rano