OGeek|极客世界-中国程序员成长平台

标题: ios - 如何以编程方式模拟 "pinch out"手势? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 13:37
标题: ios - 如何以编程方式模拟 "pinch out"手势?

我正在开发一个 iOS 应用程序。

我添加了一个 UIPinchGestureRecognizer 来监听捏合 Action 。

[[self view]addGestureRecognizer:[[UIPinchGestureRecognizer alloc] initWithTarget:self actionselector(handlePinchOutGesture]];

-(void)handlePinchOutGestureUIPinchGestureRecognizer*)recognizer {
    if (recognizer.state == UIGestureRecognizerStateBegan) {
        // Do something

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

    } else {
       // Do something

    }
}

但是,我还想添加一个 UITapGestureRecognizer,以便在用户点击项目时具有相同的效果。

有没有办法以编程方式模拟“捏出”手势?



Best Answer-推荐答案


在 iOS 上很难合成一个触摸(或多点触摸)事件:你必须使用非公共(public) 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/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4