The move:
method that you're adding to your Walker's PAN gesture is actually referencing a method built into the C4Control
class (i.e. all visual objects).
To figure out when the gesture is released, you can override the method to add a condition that checks for when the gesture's state has ended.
To do this, you first subclass a C4 object (here I'm using C4Shape, but you can use C4Image).
The header will look like this:
#import "C4Shape.h"
@interface MyShape : C4Shape
@end
The implementation will have an overridden move:
method, like this:
#import "MyShape.h"
@implementation MyShape
-(void)move:(id)sender {
[super move:sender];
UIPanGestureRecognizer *panGesture = (UIPanGestureRecognizer *)sender;
if(panGesture.state == UIGestureRecognizerStateEnded) {
[self methodToRunWhenPanGestureEnds];
}
}
-(void)methodToRunWhenPanGestureEnds {
C4Log(@"the pan gesture ended");
}
@end
... finally, in your workspace you can create a the object and add a gesture to it like you would normally.
#import "C4WorkSpace.h"
#import "MyShape.h"
@implementation C4WorkSpace
-(void)setup {
MyShape *s = [[MyShape alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
[s rect:s.frame];
[s addGesture:PAN name:@"pan" action:@"move:"];
[self.canvas addShape:s];
}
@end
You can grab a copy of a C4 project that shows how to do this from here: https://github.com/C4Code/PanGestureEnded
As for the C4View issue you were having, you're right... You won't get gestures working on C4Views at the moment. You can add regular UIGestureRecognizers to C4Views, but the method [object addGesture:name:action:]
won't work because we haven't yet implemented this for the C4View class (but it's on our todo list already).