views:

455

answers:

1

I don't have an IPhone and don't really want to pay $130 a month for a cell phone. (I leave mine in the car most of the time, sometimes the entire weekend.) But I covet the technology as a mobile computing platform. (Cruel Fate.) One of the things I like about it the most is the multitouch capability.

How does it look from an API standpoint? Does the OS have "Gestures" that it knows and passes on an event based on what the user did, or is the application required to interpret a list of "touch and release" events? How many points can it read? 2, 3... unlimited? Does Mac OS X proper have this capability if you have a "Multitouch" capabible monitor?

+3  A: 

You can always take a look at the documentation to get a better idea of what is supported, but the general methods to implement are:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;

When you tap down, touchesBegan is called with the set of touches that just began. To retrieve all touches currently on the screen, retrieve event.allTouches.

Similarily obvious actions occur when a finger moves or is removed from the screen. The touchesCancelled method is mostly used to support the UIScrollView which allows you to tap something inside a scroll view, then drag the scroll view itself rather that interact with the subview, if certain criteria are met (the scroll view would send a touches cancelled message to the subview when it starts scrolling).

There are no built-in gestures you can watch for to speak of, but there are built-in gestures that the system handles, like swiping across a row in a table to delete it, and pinch-zooming on a UIScrollView.

Ed Marty