自分の view が表示される前に別のタブで回転されている可能性があるので、回転に対応する処理をプログラムで行う場合は viewWillAppear の中でも処理を行わなくてはならない。
ruby>>
@implementation SomeViewController
(BOOL)
shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}(void)
AdjustHV {
switch ( self.interfaceOrientation ) {
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationPortraitUpsideDown:
oV1.frame = CGRectMake(
0
, 0
, self.view.frame.size.width
, self.view.frame.size.height / 2
);
oV2.frame = CGRectMake(
0
, self.view.frame.size.height / 2
, self.view.frame.size.width
, self.view.frame.size.height / 2
);
break;
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:
oV1.frame = CGRectMake(
0
, 0
, self.view.frame.size.width / 2
, self.view.frame.size.height
);
oV2.frame = CGRectMake(
self.view.frame.size.width / 2
, 0
, self.view.frame.size.width / 2
, self.view.frame.size.height
);
break;
}
}(void)
viewWillAppear:(BOOL)p {
[ super viewWillAppear:p ];
[ self AdjustHV ];
}(void)
willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)p
duration:(NSTimeInterval)pDuration {
[ super willAnimateRotationToInterfaceOrientation:p duration:pDuration ];
[ self AdjustHV ];
}
@end
<<--