I want to get notification when a user is rotate the screen to landscape or portrait,
it is possible?
I find couple of article but i didn’t found answer for this.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to be notified when the device has been rotated you can either implement the
shouldAutorotateToInterfaceOrientation:method in your view controller or you can register to receive theUIDeviceOrientationDidChangeNotification.Before we start, the device orientation and the interface orientation can be different. The device may be landscape but the interface may remain portrait depending on how the app has been written. Device notifications are sent shortly before the interface orientation is changed to match the device orientation. If you don’t want the interface orientation to change you should implement the
shouldAutorotateToInterfaceOrientation:method in your view controller to returnNO. This will stop the interface orientation being updated.From your question it sounds like you want to receive notifications so I think you want to use the second method. You can enable
UIDeviceOrientationChangeNotifications using:There is a corresponding:
You can register to receive the notifications in the normal way, using the
NSNotificationCenterand registering to receive theUIDeviceOrientationDidChangeNotification:Finally, you would implement the method to be called when the notification is received as follows:
As you can see, the orientation can be accessed using the
orientationinstance method ofUIDevice.