drawRect メソッドをオーバーライドする必要があったため、UIView のカスタム サブクラスを作成しました。UITapGestureRecognizer を追加しようとしましたが、うまくいきません。ここで、私のViewControllerのコード:
MyCustomView *customView = [[MyCustomView alloc] initWithFrame:CGRectFrame(0, 30, 30, 30)];
[customView setUserInteractionEnabled:YES];
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doSomething)];
[customView addGestureRecognizer:tapGestureRecognizer];
UIView サブクラス オブジェクトに触れたときにジェスチャ認識エンジンが起動しない理由がわかりません。
よろしくお願いします!
修正しました!
私のビューはUIImageViewにあり、そのUIImageViewはuserInteractionEnabled
YESに設定されていませんでした。