How do I detect the rotation of the iPhone for approximately 90 degrees? Additionally, I don't need/want the screen itself to rotate. I just want to call a function when the phone has been rotated. Thanks!
+5
A:
Your view controller will be sent:
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
Implement it to do something when the phone is being rotated
After the rotation is done, you get:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
Here it is in the docs (see Handling View Rotations)
Lou Franco
2009-06-22 20:06:56
+1
A:
When you rotate the device, your view controller receives a didRotateFromInterfaceOrientation: message, with the old orientation. You can check the interfaceOrientation property to see the current rotation, and do something accordingly.
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
Zydeco
2009-06-22 20:08:04
+1
A:
You need to catch the events sent prior to ViewController rotation. Namely:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
and post rotation
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
KiwiBastard
2009-06-22 20:09:18