Objective c 在shouldAutorotateToInterfaceOrientation上,如何选择UIView旋转方向?
当我旋转iPhone时,我希望UIView以与它所做的相反的方向旋转。 如何选择旋转方向Objective c 在shouldAutorotateToInterfaceOrientation上,如何选择UIView旋转方向?,objective-c,cocoa-touch,Objective C,Cocoa Touch,当我旋转iPhone时,我希望UIView以与它所做的相反的方向旋转。 如何选择旋转方向 thx在willAutorotateToInterfaceOrientation中,放置一个IF语句 #define DEGREES_TO_RADIANS(angle) (angle / 180.0 * M_PI) if (interfaceOrientation == UIInterfaceOrientationPortrait) { //Rotate view here by 180 deg
thx在
willAutorotateToInterfaceOrientation
中,放置一个IF语句
#define DEGREES_TO_RADIANS(angle) (angle / 180.0 * M_PI)
if (interfaceOrientation == UIInterfaceOrientationPortrait) {
//Rotate view here by 180 degrees
CGAffineTransform rotation = CGAffineTransformIdentity;
rotation = CGAffineTransformRotate(rotationTransform, DEGREES_TO_RADIANS(180));
view.transform = rotation;
}
请注意,旋转到与用户期望相反的方向将导致您的应用被拒绝。顺便说一句,您通常不应该在
shouldAutorotateToInterfaceOrientation:
中进行类似的更改,而应该在willAutorotateToInterfaceOrientation:
中进行更改“应该”应该快速有效地确定是否允许发生轮换。哎呀,这就是我的意思。谢谢你指出这一点!