iPhone rotation on demand
Is there a way to manually check current position of device AND ask开发者_JAVA百科 device to automatically rotate it without waiting for user to actually rotate the device?
Currently I control the rotation with several IFs in -shouldAutorotateToInterfaceOrientation but in few situations I have to stop the view from rotating and enable it again and I don't want user to rotate the device twice to have the desired orientation.
for checking Orientation
UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
then based on your condition you can change device orientation as you wish..
you can use :
[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationPortrait;
or what ever you want.
or you can go for following but this is not do
[[UIDevice currentDevice] setOrientation:UIDeviceOrientationPortrait];
精彩评论