Reputation: 2399
I am using
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(detectOrientation) name:@"UIDeviceOrientationDidChangeNotification" object:nil];
to make changes to some views in my appdelegate.
But this gets called in a slightest variation of the accelerometer. Can anyone suggest any workaround, so that it gets only called when the device is completely rotated. Thanks
Upvotes: 0
Views: 1971
Reputation: 11607
Could you write some code to check the device's width = 480 and height = 320 (this is when the device has been rotated 90 degrees) before posting the notification?
So something like:
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
...
if(width == 480 && height == 320)
{
[[NSNotificationCenter defaultCenter] postNotification . . . ];
}
Upvotes: 1
Reputation: 4993
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
//your code here
}
override this method in your view controller. It will get called when the device has rotated to a new orientation
Upvotes: 0