C4 has a method that simplifies the process of adding gestures to any visible object (for example, C4Shape, C4Movie, C4Label ...).
NOTE : you will need to create a subclass of C4Shape in which you can create some custom methods.
For example, the following will add a binding gesture to C4Shape:
C4Shape *s = [C4Shape rect:CGRectMake(..)]; [s addGesture:TAP name:@"singleTapGesture" action:@"tap"];
The addGesture:name:action:
method is specified in the C4Control documentation and defined as:
Adds a gesture to the object.
- (void)addGesture:(C4GestureType)type name:(NSString *)gestureName action:(NSString *)methodName
(C4GestureType)type
can be any of:
- Tap
- SWIPERIGHT
- SWIPELEFT
- Swipeup
- SWIPEDOWN
- Pan
- LONGPRESS
The following gestures are available but have not yet been tested:
(NSString *)gestureName
allows (NSString *)gestureName
to specify a unique name for gestures.
(NSString *)methodName
allows you to specify the method that will call this gesture.
So ... back to the above example:
[s addGesture:TAP name:@"singleTapGesture" action:@"tap"];
... will add a gesture called singleTapGesture
to the object s
a TAP
, which, when launched, will launch the -(void)tap;
method -(void)tap;
(which should already be defined in your class).
You can apply the technique described above, but instead use:
[s addGesture:PAN name:@"panGesture" action:@"move:];
you will also need to determine
-(void)move:(id)sender;
in your form class.