2012-03-16 32 views
0

我已經實現了一個自定義的UIButton,爲了讓我能夠處理LongPress事件(不使用手勢識別器),我不得不在我的課上使用touchesBegan:,touchesEnded:。問題是現在常規按鈕事件不起作用。我想知道是什麼造成這種情況,以及我如何避免它?TouchesBegan覆蓋touchUpInside行動

基於觸摸的事件正在運行,但之前我對touchUpInside:的操作不再起作用。

感謝

回答

1

不使用touchesBegan:爲長按,用這個手勢識別!

UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc]  initWithTarget:self action:@selector(longTap:)]; 
[view addGestureRecognizer:longPressGesture]; 
[longPressGesture release]; 

-(void) longTap:(UILongPressGestureRecognizer *)gestureRecognizer{ 
    NSLog(@"gestureRecognizer= %@",gestureRecognizer); 
    if ([gestureRecognizer state] == UIGestureRecognizerStateBegan) { 
     NSLog(@"longTap began"); 
    } 
} 
+0

我想避免這種情況。手勢識別器限制了我的iOS目標受衆。我想擺脫它。 – MrShoot 2012-03-16 14:45:31

+1

你是什麼意思?手勢識別器已經存在,因爲iOS3.2!沒有人使用2.0了..幾乎世界上每個人都至少在iOS 4.0上! – 2012-03-16 14:55:58

+0

一些要求我無法通過:P – MrShoot 2012-03-16 14:59:39