gpt4 book ai didi

iphone - 长按并单击按钮

转载 作者:可可西里 更新时间:2023-11-01 05:41:57 24 4
gpt4 key购买 nike

如何获取按钮的单次点击或长按点击事件?

最佳答案

检查这段代码

//Add Long Press Gesture Reconizer
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]
initWithTarget:self action:@selector(handleLongPress:)];
longPress.minimumPressDuration = 3; //seconds
longPress.delegate = self;
[yourButton addGestureRecognizer:longPress];

//Add button touch
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapDetected:)];
tapGesture.numberOfTapsRequired = 1;
tapGesture.numberOfTouchesRequired = 1;
[yourButton addGestureRecognizer:tapGesture];
//For touch you can also set selector for button event with Controlevent touchupinside


-(void) handleLongPress : (id)sender
{
//Long Press done by the user
}

-(void) tapDetected : (id) sender
{
//Button Tapped by user
}

关于iphone - 长按并单击按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12197212/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com