ios ios模拟器:模拟滑动和拖动

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7361971/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 21:26:28  来源:igfitidea点击:

ios simulator: simulate swipe and drag

objective-ciosdragswipeios-simulator

提问by Srisa

I have a UIView within a UIScrollView. When i want to simulate the drag event on the UIView, swipe event on the UIScrollView is being triggered.

我在 UIScrollView 中有一个 UIView。当我想模拟 UIView 上的拖动事件时,正在触发 UIScrollView 上的滑动事件。

As per the documentation, there isn't much of a difference between swipe and drag.
Swipe

根据文档,滑动和拖动之间没有太大区别。
滑动

1- Place the pointer at the start position.  
2- Hold the mouse button. 
3- Move the pointer in the swipe direction and release the mouse button.


Drag



1- Place the pointer at the start position.
2- Hold down the mouse button.
3- Move the pointer in the drag direction.

On an ipad I can use two fingers two swipe and one finger to drag. Now, how do i go about doing something similar on the simulator; drag instead of a swipe?

在 ipad 上,我可以使用两根手指两次滑动和一根手指拖动。现在,我如何在模拟器上做类似的事情;拖动而不是滑动?

Edit 1: I should have been clearer first up. Anyway, my problem is that the mouse drag is firing the swipe instead of drag, thereby scrolling the scroll view instead of passing on the drag event to the UIView contained by the scroll view. I am on macbook pro. Two-finger swipe on the touchpad is being ignored. Touch and drag is causing the same thing as mouse-drag. Thanks

编辑 1:我应该首先更清楚。无论如何,我的问题是鼠标拖动触发滑动而不是拖动,从而滚动滚动视图而不是将拖动事件传递给滚动视图包含的 UIView。我在 macbook pro 上。触摸板上的两指滑动被忽略。触摸和拖动导致与鼠标拖动相同的事情。谢谢

采纳答案by Srisa

I ended up disabling the scrolling from the UI and added two buttons to scroll the scroll view. Since this is a work around only for the emulator, I have used #ifndef to hide the buttons while building for the device.

我最终从 UI 禁用滚动并添加了两个按钮来滚动滚动视图。由于这仅适用于模拟器,因此我在为设备构建时使用了 #ifndef 来隐藏按钮。

回答by Rob Napier

See Jeff LaMarche's quick noteon how to do this. It's documented in the same page you're reading, but Jeff's explanation is clearer.

请参阅Jeff LaMarche关于如何执行此操作的快速说明。它记录在您正在阅读的同一页面中,但 Jeff 的解释更清楚。

If you want to simulate a two-finger gesture in the iPhone simulator, hold down the option key. You will get two dots on the screen instead of one. The two dots will default to pinching - if you bring the dot closer to the center of the screen, the other dot comes toward the center, making it easy to simulate a pinch in or pinch out.

If you want to do a different two-finger gesture, get the two dots the distance apart that you want them to be, then hold down the shift key, while still holding down the option key. That will lock the position of the two finger presses together so you can do, for example, a two-finger swipe.

如果要在 iPhone 模拟器中模拟两指手势,请按住选项键。您将在屏幕上看到两个点,而不是一个。这两个点将默认为捏合 - 如果您将点靠近屏幕中心,另一个点会朝向中心,从而可以轻松模拟捏合或捏合。

如果你想做一个不同的双指手势,让两个点相距你想要的距离,然后按住 shift 键,同时仍然按住 option 键。这会将两个手指按压的位置锁定在一起,因此您可以执行例如两指滑动。

回答by nyus2006

see this documentation below: iOS Simulator User Guide

请参阅以下文档: iOS 模拟器用户指南

Just use the mouse to drag the view, aka, left click the view then move the mouse

只需使用鼠标拖动视图,也就是左键单击视图然后移动鼠标