is there any difference when we use following two methods for orientation change in iOS.
1) Using NotificationCenter
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChange) name:UIDeviceOrientationDidChangeNotification object:nil];
-(void) orientationChange
{
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
NSLog(@"Orientation =%d",orientation);
NSLog(@"in Testtt");
}
2) ViewController Orientation delegate methods
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if(UIInterfaceOrientationLandscapeRight == interfaceOrientation || UIInterfaceOrientationLandscapeLeft == interfaceOrientation)
return YES;
else
return NO;
}
In first case you will receive UIDeviceOrientation.
[[UIDevice currentDevice] orientation]returns UIDeviceOrientation, device orientation. But note that UIDeviceOrientation is not always UIInterfaceOrientation. For example, when your device is on a plain table you can receive unexpected value (UIDeviceOrientationUnknown).In
shouldAutorotateToInterfaceOrientationmethod you can access UIInterfaceOrientation, current orientation of the interface.