我正在爲iPhone編寫Objective-C程序。UILongPressGestureRecognizer將不會響應觸摸和鎖定
我想實現一個UILongPressGestureRecognizer
,並不能讓它按照我想要的方式工作。
我想做的是簡單的:
響應觸摸是舉行下在屏幕上。
UILongPressGestureRecognizer
工作得很好,只要觸摸移動,觸摸開始,但如果我在同一個地方按住觸摸,什麼都不會發生。
爲什麼?
我該如何處理開始,不移動,並保持在同一個地方?
這是我目前的代碼。
// Configure the press and hold gesture recognizer
touchAndHoldRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(touchAndHold:)];
touchAndHoldRecognizer.minimumPressDuration = 0.1;
touchAndHoldRecognizer.allowableMovement = 600;
[self.view addGestureRecognizer:touchAndHoldRecognizer];
//配置按住手勢識別器 touchAndHoldRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(touchAndHold :)]; touchAndHoldRecognizer.minimumPressDuration = 0.1; touchAndHoldRecognizer.allowableMovement = 600; [self.view addGestureRecognizer:touchAndHoldRecognizer]; –
我的觀點正是如此。如果你不移動,你不會重複發生。這就是我想要解決的問題。如果我不移動,你知道一種方法可以讓我重複發生嗎? –
這應該重新打開,因爲如果你仔細看看這個問題的要求,它不是問「我該如何做一個長按手勢」,而是「現在我在長按手勢中獲得通知,甚至儘管我沒有動。「這不是其他問題的重複。 – Rob