• <i id='GFSbc'><tr id='GFSbc'><dt id='GFSbc'><q id='GFSbc'><span id='GFSbc'><b id='GFSbc'><form id='GFSbc'><ins id='GFSbc'></ins><ul id='GFSbc'></ul><sub id='GFSbc'></sub></form><legend id='GFSbc'></legend><bdo id='GFSbc'><pre id='GFSbc'><center id='GFSbc'></center></pre></bdo></b><th id='GFSbc'></th></span></q></dt></tr></i><div id='GFSbc'><tfoot id='GFSbc'></tfoot><dl id='GFSbc'><fieldset id='GFSbc'></fieldset></dl></div>
      <bdo id='GFSbc'></bdo><ul id='GFSbc'></ul>
  • <legend id='GFSbc'><style id='GFSbc'><dir id='GFSbc'><q id='GFSbc'></q></dir></style></legend>

    1. <small id='GFSbc'></small><noframes id='GFSbc'>

      <tfoot id='GFSbc'></tfoot>

        如何通过手指触摸自动围绕中心点旋转图像

        时间:2023-05-19
          <tbody id='45I5H'></tbody>
        <legend id='45I5H'><style id='45I5H'><dir id='45I5H'><q id='45I5H'></q></dir></style></legend>
          <bdo id='45I5H'></bdo><ul id='45I5H'></ul>

              <tfoot id='45I5H'></tfoot>
              <i id='45I5H'><tr id='45I5H'><dt id='45I5H'><q id='45I5H'><span id='45I5H'><b id='45I5H'><form id='45I5H'><ins id='45I5H'></ins><ul id='45I5H'></ul><sub id='45I5H'></sub></form><legend id='45I5H'></legend><bdo id='45I5H'><pre id='45I5H'><center id='45I5H'></center></pre></bdo></b><th id='45I5H'></th></span></q></dt></tr></i><div id='45I5H'><tfoot id='45I5H'></tfoot><dl id='45I5H'><fieldset id='45I5H'></fieldset></dl></div>

              <small id='45I5H'></small><noframes id='45I5H'>

                • 本文介绍了如何通过手指触摸自动围绕中心点旋转图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  在iPhone上,如何使用手指触摸实现围绕中心点旋转图像?

                  On iPhone, how to implement rotating image around the center point using finger touch ?

                  就像滚轮一样,如果你把手指放在iPhone屏幕上,然后突然移动,然后图像像滚轮一样围绕中心点旋转,过了一会儿,它变得越来越慢,最后停止了.

                  Just like wheel, if you put finger on the iPhone screen , then move suddenly, then the image becoming rotating around center point just like the wheel, after a while, it becomes more and more slow , finally stop.

                  谁能帮忙给出一些代码(Object-C)或一些建议?

                  Who can help to give some pieces of codes (Object-C) or some suggest ?

                  推荐答案

                  我昨天正在使用旋转瓶子"应用程序.在窗口上,我有一个带有瓶子的 ImageView,它可以响应触摸并旋转用户滑动手指的方式.在触摸事件(TouchesBegan、Touchesoved、TouchesEnd)期间,我很难让我的 ImageView 旋转.我在 TouchesMoved 中使用了这段代码来找出女巫旋转图像的角度.

                  I was working with a "spin the bottle"-app yesterday. On the window I have a ImageView with an bottle that's suppose to response to touches and rotate the way the user swipes his finger. I struggled to get my ImageView to rotate during the touch-events (TouchesBegan, Touchesoved, TouchesEnd). I used this code in TouchesMoved to find out the angle in witch to rotate the image.

                  public override void TouchesMoved (NSSet touches, UIEvent evt)
                  {    
                    PointF pt = (touches.AnyObject as UITouch).LocationInView(this);
                  
                    float x = pt.X  - this.Center.X;
                    float y = pt.Y  - this.Center.Y;
                    double ang =  Math.Atan2(x,y);
                  
                    // yada yada, rotate image using this.Transform
                  }
                  

                  这很重要!当 ImageView 旋转时,即使是 x &y 坐标会发生变化. 所以一直触摸同一个区域会给我在 pt 点和 prePt 点中的不同值.经过一番思考、谷歌搜索和阅读,我想出了一个简单的解决方案.ImageView 的SuperView"属性.

                  THIS IS IMPORTANT! When the ImageView rotates, even the x & y-coordinates changes. So touching the same area all the time would give me different values in the pt and prePt-points. After some thinking, googeling and reading I came up with an simple solution to the problem. The "SuperView"-property of the ImageView.

                  PointF pt = (touches.AnyObject as UITouch).LocationInView(this.SuperView);
                  

                  有了这个小改动让它变得容易多了,不,我可以使用 UITouch-metohs LocationInView 和 PreviousLocationInView 并获得正确的 x &y 坐标.她是我代码的一部分.

                  Having that small change in place made it alot easier, no i can use the UITouch-metohs LocationInView and PreviousLocationInView and get the right x & y coordinates. Her is parts of my code.

                  float deltaAngle;
                  
                  public override void TouchesMoved (NSSet touches, UIEvent evt)
                  {
                      PointF pt = (touches.AnyObject as UITouch).LocationInView(this.Superview);
                  
                      float x = pt.X  - this.Center.X;
                      float y = pt.Y  - this.Center.Y;
                      float ang =  float.Parse(Math.Atan2(dx,dy).ToString());
                  
                  
                      //do the rotation
                       if (deltaAngle == 0.0) {
                         deltaAngle = ang;
                       }
                  else
                      {
                        float angleDif = deltaAngle - ang;
                        this.Transform = CGAffineTransform.MakeRotation(angleDif);
                      }   
                  }
                  

                  希望这可以帮助某人花费数小时来弄清楚如何旋转瓶子!:)

                  Hope that helped someone from spending hours on how to figure out how to freaking rotate a bottle! :)

                  这篇关于如何通过手指触摸自动围绕中心点旋转图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:3d 中的 Android ViewGroup 旋转 下一篇:如何检测屏幕旋转?

                  相关文章

                • <small id='4W4JK'></small><noframes id='4W4JK'>

                  <i id='4W4JK'><tr id='4W4JK'><dt id='4W4JK'><q id='4W4JK'><span id='4W4JK'><b id='4W4JK'><form id='4W4JK'><ins id='4W4JK'></ins><ul id='4W4JK'></ul><sub id='4W4JK'></sub></form><legend id='4W4JK'></legend><bdo id='4W4JK'><pre id='4W4JK'><center id='4W4JK'></center></pre></bdo></b><th id='4W4JK'></th></span></q></dt></tr></i><div id='4W4JK'><tfoot id='4W4JK'></tfoot><dl id='4W4JK'><fieldset id='4W4JK'></fieldset></dl></div>
                • <legend id='4W4JK'><style id='4W4JK'><dir id='4W4JK'><q id='4W4JK'></q></dir></style></legend>

                    <tfoot id='4W4JK'></tfoot>
                        <bdo id='4W4JK'></bdo><ul id='4W4JK'></ul>