私はC4で作業していて、図形を押し下げて低速で上にドラッグできるようにしたいと考えています。「UIGestureRecognizer用のUITouchオブジェクトの取得」チュートリアルおよびその他のTouchesMovedおよびTouchesBeganObjective-Cチュートリアルを使用していますが、ジェスチャがシェイプに適用されていません。プロジェクトはビルドされますが、押してドラッグしてもシェイプは移動しません。C4がジェスチャーを図形に適用する特定の方法はありますか?
これは私のコードです:
DragGestureRecognizer.h
#import <UIKit/UIKit.h>
@interface DragGestureRecognizer : UILongPressGestureRecognizer {
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
@end
@protocol DragGestureRecognizerDelegate <UIGestureRecognizerDelegate>
- (void) gestureRecognizer:(UIGestureRecognizer *)gr movedWithTouches:(NSSet*)touches andEvent:(UIEvent *)event;
@end
C4WorkSpace.m:
#import "C4WorkSpace.h"
#import "DragGestureRecognizer.h"
@implementation DragGestureRecognizer
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesMoved:touches withEvent:event];
if ([self.delegate respondsToSelector:@selector(gestureRecognizer:movedWithTouches:andEvent:)]) {
[(id)self.delegate gestureRecognizer:self movedWithTouches:touches andEvent:event];
}
}
@end
@implementation C4WorkSpace {
C4Shape *circle;
}
- (void)longPress:(UILongPressGestureRecognizer*)gesture {
if ( gesture.state == UIGestureRecognizerStateEnded ) {
NSLog(@"Long Press");
}
}
-(void)setup {
circle = [C4Shape ellipse:CGRectMake(5,412,75,75)];
[self.canvas addShape:circle];
}
@end