再現率は100%ではない
ちょっと調べてみたが対策法はなさそうなのでUIScrollViewなどで代用するしかなさそうだ
- (void)viewDidLoad
{
[super viewDidLoad];
//iOS 4.3~5.1 回転時の呼び出しメソッドを設定
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(orientationChanged:)
name:UIDeviceOrientationDidChangeNotification
object:nil];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
//iOS 4.3~5.1 回転の停止
//他のViewControllerで使用したくないときはここでキャンセルする
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIDeviceOrientationDidChangeNotification
object:nil];
}
//iOS 6.0~ 回転をサポートするか
- (BOOL)shouldAutorotate
{
return YES;
}
//iOS 6.0~ 推奨される向き
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
//iOS 6.0~ サポートする向き
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
//iOS 4.3~5.1 回転をサポートするか?
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
//回転時の動作
- (void)orientationChanged:(NSNotification *)notification
{
}
//回転時のアニメーションを定義
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
{
}
//回転前に呼び出される
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
}
//現在のビューのサイズ、ツールバーやステータスバーのサイズは引かれる //iPhone4でステータスバー、ナビゲーションバー、ステータスバーがあるとき、heightは480-20-44-44になる self.view.frame.size.width self.view.frame.size.height //現在の端末のスクリーンサイズ //iPhone4ではheight480、iPhone5ではheight568になる [[UIScreen mainScreen] bounds].size.width [[UIScreen mainScreen] bounds].size.height //現在の端末のスクリーンサイズでステータスバー領域を含む //iPhone4ではheight460、iPhone5ではheight548になる [[UIScreen mainScreen] mainScreen].size.width [[UIScreen mainScreen] mainScreen].size.height