これを Cocos2d で動作させるには、このコードにどのような変更を加える必要がありますか? 向きが変わったときに手動で回転させるのに最適です。
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
if(UIInterfaceOrientationIsPortrait(toInterfaceOrientation)){
[self changeTheViewToPortrait:YES andDuration:duration];
}
else if(UIInterfaceOrientationIsLandscape(toInterfaceOrientation)){
[self changeTheViewToPortrait:NO andDuration:duration];
}
}
- (void) changeTheViewToPortrait:(BOOL)portrait andDuration:(NSTimeInterval)duration{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:duration];
if(portrait){
//change the view and subview frames for the portrait view
tabBar.frame = CGRectMake(0, 420, 320, 40);
}
else {
//change the view and subview frames for the landscape view
tabBar.frame = CGRectMake(0, 260, 480, 40);
}
[UIView commitAnimations];
}