Iphone 如何在设备方向改变时旋转视图,以保持窗口的正确大小
我想在使用cocos2d的iPad应用程序中支持完整的设备定位。 为了实现这一点,我想我会像以前一样为shouldAutorotateToInterfaceOrientation返回YES,当时我正在处理没有cocos2d的应用程序,但在这种情况下,我的视图无法正确调整大小。 为了向你们展示我的结局,这是一张示例图片。 您可以看到方向是横向的,但视图仍然是纵向的。Iphone 如何在设备方向改变时旋转视图,以保持窗口的正确大小,iphone,objective-c,xcode,ipad,cocos2d-iphone,Iphone,Objective C,Xcode,Ipad,Cocos2d Iphone,我想在使用cocos2d的iPad应用程序中支持完整的设备定位。 为了实现这一点,我想我会像以前一样为shouldAutorotateToInterfaceOrientation返回YES,当时我正在处理没有cocos2d的应用程序,但在这种情况下,我的视图无法正确调整大小。 为了向你们展示我的结局,这是一张示例图片。 您可以看到方向是横向的,但视图仍然是纵向的。 谁能告诉我我做错了什么 您必须设置视图的autosize属性。快速的方法是在“大小检查器”中设置它。您必须设置视图的autosiz
谁能告诉我我做错了什么 您必须设置视图的autosize属性。快速的方法是在“大小检查器”中设置它。您必须设置视图的autosize属性。快速的方法是在“尺寸检查器”中设置它添加以下功能并执行相应的更改
-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
switch (toInterfaceOrientation) {
case UIInterfaceOrientationPortrait:
break;
case UIInterfaceOrientationLandscapeLeft:
break;
case UIInterfaceOrientationLandscapeRight:
break;
case UIInterfaceOrientationPortraitUpsideDown:
break;
default:
break;
}
}
添加以下功能并执行相应的更改
-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
switch (toInterfaceOrientation) {
case UIInterfaceOrientationPortrait:
break;
case UIInterfaceOrientationLandscapeLeft:
break;
case UIInterfaceOrientationLandscapeRight:
break;
case UIInterfaceOrientationPortraitUpsideDown:
break;
default:
break;
}
}
必须设置视图的“自动调整大小”属性。快速的方法是在“大小检查器”中设置它。您必须设置视图的autosize属性。快速的方法是在“大小检查器”中设置它。不幸的是,在使用cocos2d模板时,情况并非如此。我使用的是CCNodes,不是UIViews,但感谢您的回答。不幸的是,当您使用cocos2d模板时,情况并非如此。我正在使用CCNodes,不是UIViews,但是谢谢你的回答。你能告诉我什么样的更改吗?修改最初的willRotateToInterfaceOrientation方法后,我得到了如下结果:switch(toInterfaceOrientation){case-UIInterfaceOrientationGrait:rect=CGRectMake(0,07681024);break;case-UIInterfaceOrientationAndscapeLeft:rect=CGRectMake(0,014768);break;@user1480741在哪里添加该代码?将其添加到AppDelegate.m并在其上放置断点,但始终未到达该代码。您能告诉我有哪些更改吗?修改原始的willRotateToInterfaceOrientation方法后,我得到了如下结果:切换(到InterfaceOrientation){case-UIInterfaceOrientation纵向:rect=CGRectMake(0,07681024);break;case-UIInterfaceOrientation和scapeLeft:rect=CGRectMake(0,0,1024768);break;@user1480741在哪里添加该代码?将其添加到AppDelegate.m并在其上放置断点,但从未到达该代码。