日々精進

新しく学んだことを書き留めていきます

デバイスの方向が変化しなくてもUIDeviceOrientationDidChangeNotificationが発生する

デバイスの向きが変わったタイミングで処理を行う場合、RootViewController以外ではUIDeviceOrientationDidChangeNotificationイベントで処理する。

    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    [center addObserver:self selector:@selector(receiveUIDeviceOrientationDidChangeNotification:) name:UIDeviceOrientationDidChangeNotification object:nil];

が、なんとこのイベントはデバイスの向きが変化しなくても発生する。どんなタイミングで発生するのかはよくわからないが。。イベントメソッド内で向きが変化したかどうかを判定してやらないといけない。なんでこんな仕様になってるんだ。。