ios - snapping uiview to particular angle when rotating, locks it and cannot move again -


i want use able rotate 0 degrees, 90 degrees, 180 degree, 270 degrees, not in-between. after rotating, want user not locked in rotating , rotate once again if desired. before had view rotating freely, i'm changing code.

myview uiview i'm rotating

 - (ibaction)rotation:(uirotationgesturerecognizer *)recognizer {       uiview *myview = recognizer.view;      switch (recognizer.state) {         case uigesturerecognizerstatepossible:            break;         case uigesturerecognizerstatebegan:            break;         case uigesturerecognizerstatechanged: {            cgfloat rotation = [recognizer rotation];            cgaffinetransform rotate = cgaffinetransformmakerotation(rotation);            cgaffinetransform transform = cgaffinetransformconcat(myview.transform, rotate);            myview.transform = transform;            [recognizer setrotation:0.0];                   }            break;         case uigesturerecognizerstateended:         {            nslog(@"state ended");            cgfloat radians = atan2f(myview.transform.b, myview.transform.a);            cgfloat degrees = radians * (180 / m_pi);            nslog(@"%f",degrees);             if (degrees < 90.0) {              nslog(@"less 90 degree");               myview.transform = cgaffinetransformmakerotation(radians);              [recognizer setrotation:1.570796330];            }          }          break;        default:          break; } 

then tried:

    case uigesturerecognizerstateended:     {         nslog(@"state ended");         cgfloat radians = atan2f(myview.transform.b, myview.transform.a);         cgfloat degrees = radians * (180 / m_pi);         nslog(@"%f",degrees);          if (degrees < 90.0) {             nslog(@"less 90 degree");              myview.transform = cgaffinetransformmakerotation(m_pi_2);         }     }          break;      default:          break;  } 

and gets 90 degrees locks there can no longer rotate uiview.

any ideas? thanks.

the problem forgot break @ end of uigesturerecognizerstatechanged case.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -