Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable rotation on a UISnapBehavior?

I like that UISnapBehavior snippet, but I really want to use it to slide in one direction only with a slight oscillation.

Is there a way to turn off rotation for this behavior? As SpriteKit has allowsRotation property which can be easily turned off.

like image 306
Geri Borbás Avatar asked Oct 02 '13 15:10

Geri Borbás


People also ask

How to disable screen rotation?

How to Disable Screen Rotation 1 Open Settings . 2 Click on Display . 3 Under the "Scale and layout" section, turn off the Rotation lock toggle switch. See More....

How to disable screen rotation in widget build area of MyApp?

Create SystemChrome.setPreferredOrientations () method to disable Screen rotation in Widget build area of MyApp class just before the return part. 5. Create 1 Text widget in Widget build area to show some text.

How to turn off auto rotate on my HP laptop?

How to Turn Off Auto Rotate on My HP Laptop 1 Open Settings. 2 Click on Display. 3 Under the "Scale and layout" section, turn off the Rotation lock toggle switch. See More....

How do I turn off auto-rotation on my screen?

To turn off auto-rotation using the Settings app, use these steps: 1 Open Settings. 2 Click on Display. 3 Under the "Scale and layout" section, turn off the Rotation lock toggle switch. More ...


1 Answers

Here's a better answer: A UISnapBehavior has an action property, which takes a block which gets called at every step. Setting this block like this...

snapBehavior.action = ^{ view.transform = CGAffineTransformIdentity; };

... causes the rotation to be nulled without any other side effects.

like image 162
Dan Wesnor Avatar answered Oct 13 '22 20:10

Dan Wesnor