美文网首页
IOS 长按手势触发两次事件

IOS 长按手势触发两次事件

作者: JakieZhang | 来源:发表于2016-10-27 14:29 被阅读302次

    在处理长按手势时,警告框一直弹出两次,解决方法如下:

    UILongPressGestureRecognizer*longPressGesture = [[UILongPressGestureRecognizeralloc]initWithTarget:selfaction:@selector(DeleatLogout:)];

    [selfaddGestureRecognizer:longPressGesture];

    - (void) DeleatLogout:(UILongPressGestureRecognizer*)longPress {

    if(longPress.state==UIGestureRecognizerStateBegan) {

    NSString*str = [NSStringstringWithFormat:@"您是否确定要删除%@的所有信息?",_card.binType];

    UIAlertView*alertView = [[UIAlertViewalloc]initWithTitle:@"删除卡"message:strdelegate:selfcancelButtonTitle:@"取消"otherButtonTitles:@"确认",nil];

    [[UIViewappearance]setTintColor:[UIColorcolorWithRed:177/255.0green:215/255.0blue:116/255.0alpha:1]];

    [alertViewshow];

    }else{

    NSLog(@"long pressTap state :end");

    }

    }

    相关文章

      网友评论

          本文标题:IOS 长按手势触发两次事件

          本文链接:https://www.haomeiwen.com/subject/ukxsuttx.html