我正在开发一个sdk。我想以编程方式执行添加到视图中的长按手势。我尝试更改手势识别器的状态并将消息发送到主循环,但这不会执行操作
for (UIGestureRecognizer *currentGesture in currentElement.gestureRecognizers){
if ([currentGesture isKindOfClass:[UILongPressGestureRecognizer class]]){
UILongPressGestureRecognizer *longPressGesture = (UILongPressGestureRecognizer *)currentGesture;
longPressGesture.state = UIGestureRecognizerStateBegan;
[[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01]];
longPressGesture.state = UIGestureRecognizerStateChanged;
[[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.5]];
longPressGesture.state = UIGestureRecognizerStateEnded;
[[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0]];
[longPressGesture reset];
break;
}
}
这是我尝试过的。谁能帮我解决这个问题?
此 sdks 不适用于进入应用商店的应用。