ios - Rotation issue on a horizontal angle -
i developing ios application in need rotate 6 uiviews "facing" user. rest of interface doesn't need rotated.
the code below working amazingly in simulator. when tested on phone faced problem. whenever put phone in flat origination/horizontal, understand should go portrait. idea happening , work around?
#pragma mark rotation - (bool)shouldautorotate { return no; } - (void)orientationchanged:(nsnotification *)notification { cgfloat rotationangle = [self convertorientationtoradians]; [uiview animatewithduration:0.5 animations:^{ (timerbutton *timerbutton in self.timerbuttons) { timerbutton.button.transform = cgaffinetransformmakerotation(rotationangle); } }]; } - (cgfloat)convertorientationtoradians { uideviceorientation orientation = [uidevice currentdevice].orientation; cgfloat rotationangle = 0.0; switch (orientation) { case uideviceorientationportrait: rotationangle = 0.0; break; case uideviceorientationlandscapeleft: rotationangle = m_pi / 2; break; case uideviceorientationportraitupsidedown: rotationangle = m_pi; break; case uideviceorientationlandscaperight: rotationangle = - m_pi / 2; break; default: break; } return rotationangle; }
your default value rotation angle 0, , case uideviceorientationfaceup not explicitly handled.
alternatively, call [[uiapplication sharedapplication] statusbarorientation]
rather [uidevice currentdevice].orientation
.
Comments
Post a Comment