スワイプ ジェスチャ レコグナイザを tableViewCell に追加しようとしていますが、機能しません。
これは私が自分のセルを作成する方法です:
CellIdentifier = @"EventsSentCell";
nibObjcet = [[NSBundle mainBundle] loadNibNamed:@"EventsSentCell" owner:self options:nil];
EventsSentCell *cell = [[EventsSentCell alloc] init];
cell = (EventsSentCell *)[nibObjcet objectAtIndex:0];
そして、これは私のセルが.mファイルでどのように開始されるかです:
-(id)init{
self = [super init];
if (self) {
leftSwipe = [[UISwipeGestureRecognizer alloc] init];
leftSwipe.direction= UISwipeGestureRecognizerDirectionLeft;
[leftSwipe addTarget:self action:@selector(swipedLeft)];
[self addGestureRecognizer:leftSwipe];
}
return self;
}
これは、.h ファイルでジェスチャ認識エンジンを宣言した方法です。
@property (nonatomic,strong) IBOutlet UISwipeGestureRecognizer *leftSwipe;
しかし、何らかの理由で私のメソッドが呼び出されません。
何か案は?
ありがとう
以下のコードを入れてみました:
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
NSLog(@"%@",gestureRecognizer);
return YES;
}
左にスワイプした後に得られる結果は次のとおりです。
<UILongPressGestureRecognizer: 0xa9d99a0; state = Possible; view = <UITableViewCellContentView 0xa9d8ce0>; target= <(action=_longPressGestureRecognized:, target=<EventsSentCell 0xa9d8bb0>)>>