0
UIButton
をタッチすると、touchesBegan
,touchesMoved
およびtouchesEnded
メソッドは呼び出されません。私は、連続したタッチが起こったときにイベントを実行し、タッチが終了したときにイベントをキャンセルしたい。touchesBeganとtouchesEndedはUIButtonで呼び出されません
UIButton
をタッチすると、touchesBegan
,touchesMoved
およびtouchesEnded
メソッドは呼び出されません。私は、連続したタッチが起こったときにイベントを実行し、タッチが終了したときにイベントをキャンセルしたい。touchesBeganとtouchesEndedはUIButtonで呼び出されません
UIButtonコントロールイベントを使用して、UIButtonタッチスタートとタッチエンドを追跡できます。
- (void)viewDidLoad {
[super viewDidLoad];
[self.button addTarget:self action:@selector(touchStarted:) forControlEvents:UIControlEventTouchDown];
[self.button addTarget:self action:@selector(touchEnded:) forControlEvents:UIControlEventTouchUpInside];
[self.button addTarget:self action:@selector(touchEnded:) forControlEvents:UIControlEventTouchUpOutside];
}
- (void)touchStarted:(id)sender {
NSLog(@"Touch started");
}
- (void)touchEnded:(id)sender {
NSLog(@"Touch ended");
}
[touchesbegan /移動/ Xcodeの6.3で動作していない終了]の可能な重複(http://stackoverflow.com/questions/29552897/touchesbegan-moved-ended-not-working-with-xcode-6- 3) – kb920
ボタンとすべてのスーパービューで 'userInteractionEnabled'がtrueに設定されていることを確認します。ほとんどの 'UIViews'ではデフォルトでtrueですが、いくつかの例外があります。 – Hamish
uibuttonの場合これは呼び出されません –