このコードをすべてのviewControllerに入れました:
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (orientation == UIInterfaceOrientationLandscapeRight) {
CGAffineTransform transform = self.view.transform;
// Use the status bar frame to determine the center point of the window's content area.
//CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
//CGRect bounds = CGRectMake(0, 0, statusBarFrame.size.height, statusBarFrame.origin.x);
CGPoint center = CGPointMake(320/2, 480/2);
// Set the center point of the view to the center point of the window's content area.
self.view.center = center;
// Rotate the view 90 degrees around its new center point.
transform = CGAffineTransformRotate(transform, (M_PI / 2.0));
self.view.transform = transform;
}
そして私も持っています:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
コードが正常に機能していることはわかりますが、まれに、ビューをメイン ビューに戻した後、メイン ビュー コントローラーがランドスケープ モードで回転しないことがあります。それが発生する可能性は非常にまれですが、これは私を悩ませています. また、iPhone でより頻繁に発生していることがわかります。シミュレーターでは、決して起こらないことを思い出しました。これについて考えられる原因は何ですか?前もって感謝します。