at iPhoneOS 3.1.2
shouldAuto
それで無理くり何とかする方法を考案した。けど、この方法では(もう少し改善すればできるかもしれないが)重力方向への回転しかできない。
shouldAuto
1 - (void)rotateNow{ 2 UIDevice *device = [UIDevice currentDevice]; 3 self.toRot ate = device.ori entation; 4 NSNotifica tion *notificati on = [NSNotifica tion notificati onWithName :@"UIDeviceOr ientationD idChangeNo tification " object:device]; 5 [[NSNotifica tionCenter defaultCen ter] postNotifi cation:notificati on]; 6 } 7 8 - (BOOL)shouldAuto rotateToIn terfaceOri entation:(UIInterfac eOrientati on)interfaceO rientation { 9 if(self.toRot ate){ 10 return interfaceO rient == self.toRot ate; 11 }else{ 12 return NO; 13 } 14 }
こんな感じ。何をしたかったかと言うと向きが変わったときにいきなり回転させるんじゃなくて、ちょっとボタンをだして確認を取りたかった。だからタイミングだけずらして回転方向は重力方向だけでいいやって話しなんだけど。
もしかすると、このNSNotifica
まぁ何にせよ。かなりhackな方法だからOSのバージョン上がったら使えなくなるかもしれない。