Is it possible to do an edge swipe in iOS simulator?
Asked Answered
A

2

20

iOS 7 provides for a UIScreenEdgePanGestureRecognizer which detects swipes in from edges of the screen. Can this gesture be simulated using the iOS7 simulator in Xcode? Clicking and dragging outside the screen area just moves the whole simulator frame around.

Allantois answered 1/10, 2013 at 22:56 Comment(0)
S
22

You don't have to swipe across the edges to trigger a UIScreenEdgePanGestureRecognizer, just start very close to the edge. It works if I start not more than ~15 points from the edge.

(this if for the simulator. I never tested this on a device)


As a side note: You have to create a gestureRecognizer for each edge. You can't OR edges together, so UIRectEdgeAll won't work.

Soso answered 1/10, 2013 at 23:5 Comment(4)
In the documentation, it gives the impression that we are able to OR the edges together. But in practice, you are right that each edge is treated separately.Fend
I upvoted you because of the side note. I was debugging the OR for a while until I realized that this is indeed the case. I don't know if it was implied but I did not get the sense from the documentationArchle
Thanks @Jon! It wasn't working until I did that. Here's a sample Xcode project and code for the UIScreenEdgePanGestureRecognizer.Flatcar
The newer answer from 2020 is a far better way to go. Thanks.Quadruplet
M
38

On Simulator Version 11.4 I see the option

  • Window -> Show Device Bezels

which shows a virtual device frame around the simulated phone:

enter image description here

This allows to start the gesture "outside" of the screen. I could successfully trigger a UIScreenEdgePanGestureRecognizer from the left.

Mechellemechlin answered 9/4, 2020 at 12:8 Comment(1)
I have been struggling with this all day long. It is working now with the default configuration of the navigation controller when dragging from the bezel. Thank you!Misesteem
S
22

You don't have to swipe across the edges to trigger a UIScreenEdgePanGestureRecognizer, just start very close to the edge. It works if I start not more than ~15 points from the edge.

(this if for the simulator. I never tested this on a device)


As a side note: You have to create a gestureRecognizer for each edge. You can't OR edges together, so UIRectEdgeAll won't work.

Soso answered 1/10, 2013 at 23:5 Comment(4)
In the documentation, it gives the impression that we are able to OR the edges together. But in practice, you are right that each edge is treated separately.Fend
I upvoted you because of the side note. I was debugging the OR for a while until I realized that this is indeed the case. I don't know if it was implied but I did not get the sense from the documentationArchle
Thanks @Jon! It wasn't working until I did that. Here's a sample Xcode project and code for the UIScreenEdgePanGestureRecognizer.Flatcar
The newer answer from 2020 is a far better way to go. Thanks.Quadruplet

© 2022 - 2024 — McMap. All rights reserved.