72508

Why I use “pan” after rotae will make view go opposite way?

Question:

Why using "pan" after rotate makes view go opposite way?

It seems these two gesture are use diffrent coordinate system? Rotation use the one is rotated,and pan use the normal one?

And if the view is rotated nearby 0' or 360 ',pan will be normal,and if the view is rotated more colse to 180',the "pan" will make view go opposite more.

Thanks.

<img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/kQWn3.jpg" data-original="https://i.stack.imgur.com/kQWn3.jpg" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

Answer1:

The point is that in your handRotate method you are assigning a rotation transformation to your view. This entails a permanent (until you modify the transformation again) change in the way your view is displayed within its superview, and the rotation transformation will be always "added" to whatever other change you do to the geometrical properties of your view.

What explains the behavior you are seeing is the interplay between the position of your view and its <em>anchor point</em>, as explained in <a href="http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/CoreAnimation_guide/Articles/Layers.html#//apple_ref/doc/uid/TP40006082" rel="nofollow">Layer Geometry and Transform</a>. In other words, the center property you are modifying when panning is the result of applying all the transforms that you have defined for your view. On the other hand, what you are trying to do when panning would require modifying the position of the view <em>before</em> the transformation are applied.

A way to go about this is reframing your code by using layers (CALayer) and modifying the layer position property instead of the view center. Like in:

recognizer.view.layer.position = ...

I think that this should fix it.

(You will need to import QuartzCore for that to compile).

Hope this helps.

Recommend

  • How do I enable a third party payment gateway which Shopify does not want to support?
  • Script needs to be run as a Celery task. What consequences does this have?
  • Extracting multiple substrings that come after certain characters in a string using stringi in R
  • Convert a statement with adjective in RDF triple
  • matrices vs. arrays of arrays in C++ and their dynamic allocation
  • UIView animation with CGAffineTransformMakeScale changes size instantly with decimal number
  • XslTransform with xml-stylesheet
  • cross combine two RDDs using pyspark
  • image auto rotates while reading url from file upload (when it's a big image)?
  • Three js, get the vector3 that pointerlockcontrolsi s facing
  • How do I make a continuous loop with the animate method?
  • How to get phone heading for augmented reality?
  • Changing One Tag Name in an XML File Using XSLT
  • RewriteCond and RewriteRule in .htaccess
  • How to reset the selected index dropdown value in html?
  • How to create a dollar amount input field in an HTML form?
  • Resizing ToolStripButtons to fit complete BackGround image
  • Delphi: Form becomes Frozen while assigning strings in thread
  • Animating an SVG Group
  • javascript variables, What does var x = a = {} do?
  • Persistent stty Settings?
  • Spring security - same page to deliver different content based on user role
  • css background images not always displayed
  • You tube videos are not playing
  • Changing Jupyter Notebook start up folder by modifying “start in” not working any more
  • how to solve invalid conversion specifier warning in iphone app
  • Universal Image Loader reuse images
  • How to copy styled text in JTextPane
  • How to autopopulate a field in SugarCRM form
  • OOP Javascript - Is “get property” method necessary?
  • AJAX Html Editor Extender upload image appearing blank
  • Master page gives error
  • Window Size for Mac application
  • WinForms: two way TextBox problem
  • Redux, normalised entities and lodash merge
  • Calling of Constructors in a Java
  • Traverse Array and Display in markup
  • Transpose CSV data with awk (pivot transformation)
  • Why can't I rebase on to an ancestor of source changesets if on a different branch?
  • Why joiner is not used after Sequence generator or Update statergy