我必須繼續這樣的類iphone,應用程序認爲我按住按鈕2次
@interface UIGestureHolder : UILongPressGestureRecognizer {
int tag;
}
@property (nonatomic, readwrite) int tag;
@end
@implementation UIGestureHolder
@synthesize tag;
@end
然後我給你這一個按鈕,這樣,當它舉行buttonheld功能呼籲:
UIGestureHolder *longpressGesture = [[UIGestureHolder alloc] initWithTarget:self action:@selector(buttonHeld:)];
longpressGesture.minimumPressDuration = 1.5;
[longpressGesture setDelegate:self];
longpressGesture.tag=i;
[contactButton addGestureRecognizer:longpressGesture];
[longpressGesture release];
按鈕功能:
-(void)buttonHeld:(id)sender
{
int i = ((UIControl *) sender).tag;
......
}
當我按住按鈕1.5秒或任何我想要的時間,運行時告訴我我按了按鈕t爲什麼每次1.5倍?它以後會導致例外。
爲什麼運行時認爲我按住按鈕兩次?