0
私たちがiOSのオリエンテーションの変更に次の2つの方法を使用すると、違いはありますか?最初のケースでオリエンテーションの変更
[[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通知センター使い方
1))のViewControllerオリエンテーションデリゲートメソッド
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if(UIInterfaceOrientationLandscapeRight == interfaceOrientation || UIInterfaceOrientationLandscapeLeft == interfaceOrientation)
return YES;
else
return NO;
}