gpt4 book ai didi

ios - 如何以编程方式模拟 "pinch out"手势?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:41:09 28 4
gpt4 key购买 nike

我正在开发 iOS 应用。

我添加了一个 UIPinchGestureRecognizer 来监听双指张开 Action 。

[[self view]addGestureRecognizer:[[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinchOutGesture:)]];

-(void)handlePinchOutGesture:(UIPinchGestureRecognizer*)recognizer {
if (recognizer.state == UIGestureRecognizerStateBegan) {
// Do something

} else if (recognizer.state == UIGestureRecognizerStateChanged) {
// Do something

} else {
// Do something

}
}

但是,我还想添加一个 UITapGestureRecognizer,这样当用户点击一个项目时它会产生相同的效果。

有没有办法以编程方式模拟“双指张开”手势?

最佳答案

在 iOS 上很难合成一个触摸(或多点触摸)事件:你必须使用非公开的 API,所以你很可能在 Apple 审查中被拒绝。

这是一个演示如何在 iPhone 上合成触摸事件的链接

http://www.cocoawithlove.com/2008/10/synthesizing-touch-event-on-iphone.html

关于ios - 如何以编程方式模拟 "pinch out"手势?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18276239/

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