[英]When the user changes device orientation, how to rotate only the navigation bar and not the view?
[英]how to rotate view when device orientation changes keeping the correct size of window
我想在使用cocos2d的iPad應用程序中支持完整的設備方向。 為此,我想我應該像以前在沒有cocos2d的應用程序上工作時那樣為shouldAutorotateToInterfaceOrientation返回YES,但是在這種情況下,我的視圖無法正確調整大小。 為了向您展示我的最終結果,它是示例圖片。
您可以看到方向為橫向,但視圖仍為縱向。 有人可以告訴我我在做什么錯嗎?
添加以下功能並執行相應的更改
-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
switch (toInterfaceOrientation) {
case UIInterfaceOrientationPortrait:
break;
case UIInterfaceOrientationLandscapeLeft:
break;
case UIInterfaceOrientationLandscapeRight:
break;
case UIInterfaceOrientationPortraitUpsideDown:
break;
default:
break;
}
}
您必須設置視圖的autosize屬性。 快速的方法是在“尺寸檢查器”中進行設置
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.