0
當我們在iOS中使用以下兩種方法更改方向時,是否有任何區別。方向更改
1)使用通知中心
[[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取向委託方法
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if(UIInterfaceOrientationLandscapeRight == interfaceOrientation || UIInterfaceOrientationLandscapeLeft == interfaceOrientation)
return YES;
else
return NO;
}