如何在屏幕上显示所有触摸以演示 iPhone 应用程序?

发布于 2024-11-19 19:59:55 字数 257 浏览 1 评论 0原文

现在我们在 iPad 2 上有了显示镜像(现在是有线的……iOS 5 中也有无线),有没有一种简单的方法可以在屏幕上显示所有触摸?这在演示应用程序时有用吗?

我正在寻找的是能够仅包含一些 SDK,并且可能更改一行代码,之后我的所有触摸都将显示在屏幕上。

我见过许多其他演示应用程序的方法: 1)使用模拟器和屏幕捕获工具,将鼠标光标变成一个大的白色圆圈 2)越狱黑客可以记录屏幕/显示所有触摸

但是,我的目标是仅在实际设备上运行的常规应用程序上显示触摸。

Now that we have display mirroring on the iPad 2 (wired now... wireless coming in iOS 5), is there an easy way to display all touches on screen? This would be useful when demoing an app?

What I am looking for is the ability to just include some SDK, and maybe change a line of code after which all of my touches will be displayed on screen.

I have seen many other ways to demo apps:
1)Using the simulator along with a screen capture tool that will turn your mouse cursor into a big white circle
2)Jailbreak hacks that can record the screen/display all touches

However, my goal is to just have touches displayed on a regular app running on an actual device.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

離殇 2024-11-26 19:59:55

我意识到这个问题现在已经很老了,但是现有的解决方案对我来说都不够好。我需要一些可以在多个窗口中开箱即用的东西,而不必对窗口进行子类化或进行任何摆弄。

所以我创建了 ShowTime,它(直到 Swift 4)实际上只需要您将 pod 添加到您的 podfile 或将 ShowTime.swift 添加到您的目标。其余的都是完全自动的,除非您想配置默认值。

https://github.com/KaneCheshire/ShowTime

从 Swift 4 开始,还有一个额外的步骤,在您的 AppDelegate 中,只需设置 ShowTime.enabled = .alwaysShowTime.enabled = .debugOnly

编辑:Swift 4 现在再次自动启用所以不需要手动启用。

I realise this question is old now, but none of the existing solutions were good enough for me. I needed something that worked out of the box with multiple windows, without having to subclass windows or do any fiddling about.

So I created ShowTime, which (up until Swift 4) literally just requires you to either add the pod to your podfile or add ShowTime.swift to your target. The rest is totally automatic unless you want to configure the defaults.

https://github.com/KaneCheshire/ShowTime

Starting from Swift 4 there's one extra step, in your AppDelegate, just set ShowTime.enabled = .always or ShowTime.enabled = .debugOnly

Edit: Swift 4 now has auto-enabling again so no need to manually enable.

久夏青 2024-11-26 19:59:55

您可以使用 Touchposé:https://github.com/toddreed/Touchpose

沦落红尘 2024-11-26 19:59:55

在查看了所有不同的库之后,我意识到,至少就我而言,它们是巨大的杀伤力。我只是想制作一个应用程序预览视频,并且我只需要在应用程序中的两个位置使用它。

因此,我花了一点时间想出了以下代码,您可以将其与基于 SpriteKit 的场景一起使用,以逐个场景地启用触摸显示。 (并且,如果您从头开始,您可以子类化 SKScene 并将其直接烘焙以供所有场景使用。)

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    CGPoint location = [touch locationInNode:self];
    SKNode *node = [self nodeAtPoint:location];

#ifdef weBeRecording
    // ^^ Only do this if we're building a special version for making App Previews
    // Could also be switched on and off by a runtime control, I suppose

    // Create a new SKSprite at the touch location
    SKSpriteNode *touchesNode = [SKSpriteNode spriteNodeWithImageNamed:@"touchMarker.png"];
    touchesNode.position = location;

    // Initially see-through
    touchesNode.alpha = 0.0;

    // Position it above all your other nodes
    touchesNode.zPosition = 199;

    // And size it appropriately for your needs
    touchesNode.size = CGSizeMake(80, 80);

    // Add it to the scene
    [self addChild:touchesNode];

    // And then make it fade in and out. (Adjust in and out times as needed.)
    SKAction *showTouch =
    [SKAction sequence:@[
                         [SKAction fadeInWithDuration:0.25],
                         [SKAction fadeOutWithDuration:0.25],
                         [SKAction removeFromParent]
                         ]];
    [touchesNode runAction:showTouch];
#endif

    /* process original touch on node here */
}

当然,您必须自己制作 touchMarker.png 文件。我在 Photoshop 中创建了我的,它只是一个简单的 100x100 白色圆圈,透明度为 50%。老实说,获得正确的图像所花费的时间比让代码正常运行所花费的时间要长。 (如果有办法在这里附加图像,我会这样做。但是,嗯,这是我的第一天。是的。)

需要注意的是,您已经找到并保存了最初触摸的节点(保存在“节点”变量中) )在执行此操作之前。如果不这样做,原始值就会丢失,并且在显示触摸标记后,所有节点测试都将不起作用。

希望这对其他人有帮助!

迪兹

After looking at all of the various libraries for this, I realized that, at least in my case, they were massive overkill. I just wanted to make an App Preview video, and I just needed it for two places in my app.

So, I spent a little time and came up with the following code that you can use with a SpriteKit-based scene to enable touch display on a scene-by-scene basis. (And, if you are starting from scratch, you could subclass SKScene and bake this right in for use by all your scenes.)

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    CGPoint location = [touch locationInNode:self];
    SKNode *node = [self nodeAtPoint:location];

#ifdef weBeRecording
    // ^^ Only do this if we're building a special version for making App Previews
    // Could also be switched on and off by a runtime control, I suppose

    // Create a new SKSprite at the touch location
    SKSpriteNode *touchesNode = [SKSpriteNode spriteNodeWithImageNamed:@"touchMarker.png"];
    touchesNode.position = location;

    // Initially see-through
    touchesNode.alpha = 0.0;

    // Position it above all your other nodes
    touchesNode.zPosition = 199;

    // And size it appropriately for your needs
    touchesNode.size = CGSizeMake(80, 80);

    // Add it to the scene
    [self addChild:touchesNode];

    // And then make it fade in and out. (Adjust in and out times as needed.)
    SKAction *showTouch =
    [SKAction sequence:@[
                         [SKAction fadeInWithDuration:0.25],
                         [SKAction fadeOutWithDuration:0.25],
                         [SKAction removeFromParent]
                         ]];
    [touchesNode runAction:showTouch];
#endif

    /* process original touch on node here */
}

Of course, you'll have to make the touchMarker.png file yourself. I created mine in Photoshop and it's just a simple 100x100 white circle with a 50% transparency. Honestly, it took longer to get that image just right than it did to get the code working. (If there's a way to attach images here, I'll do that. But, um, it's my first day. Yeah.)

One caveat, you have find and save off the originally touched node (saved here in the "node" variable) before you do this. If you don't, that original value gets lost and none of your node testing will work after you display the touch marker.

Hope this helps someone else!

Diz

情绪 2024-11-26 19:59:55

您必须在容器视图上编写自定义触摸,并将圆形视图的中心移动到触摸的 locationInView。

You'd have to code in custom touches on the container view and move the center of a circular view to the touch's locationInView.

很酷又爱笑 2024-11-26 19:59:55

我可能会尝试使用touchesBegan、touchesMoved 和touchesEnded 来捕获KeyWindow 上的所有触摸。然后,您可以在应用程序上显示一个透明视图,然后在适当的位置显示触摸。

I would probably try to capture all touches on the KeyWindow with touchesBegan, touchesMoved and touchesEnded. You could then have a transparent view lying over the application which would then show the touches at the appropriate location.

枕梦 2024-11-26 19:59:55

我最近拼凑出的一个替代解决方案使您能够定位任何应用程序(包括 SpringBoard 和其他 iOS 系统应用程序,即“设置”),并且需要您自己的应用程序进行零修改或库,唯一的缺点是它需要越狱。我想无论如何我都会分享,以防其他人发现它有用。

https://github.com/lechium/touchy

我基于它 https://github.com/mapbox/Fingertips 但注入 UIWindow 而不是替换它以添加显示触摸所需的所有内容。

如果您已越狱,但不想自行构建和安装 touchy,请在我的 Cydia 存储库上查看: https://nitosoft .com/beta2

An alternative solution I cobbled together recently enables you to target any app (including SpringBoard and other iOS system applications ie Settings) and requires zero modifications or libraries for your own application, the only drawback is it requires a jailbreak. I figured i'd share regardless just in case anyone else finds it useful.

https://github.com/lechium/touchy

I based it around https://github.com/mapbox/Fingertips but inject into UIWindow instead of replacing it to add everything necessary to make showing the touches possible.

If you are jailbroken but don't feel like building and installing touchy on your own its on my Cydia repo: https://nitosoft.com/beta2

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文