Nun*_*ter 2 iphone rotation uiview ipad uiinterfaceorientation
我试图使我的应用程序在横向和纵向工作.我在所有的viewcontrollers中安装了正确的方法,这个代码在ipad模拟器旋转时触发,但总是触发纵向.横向IF子句永远不会被触发.我能做错什么?
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)InterfaceOrientation {
NSLog(@"******* ROTATING ******");
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
if(UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) {
NSLog(@"ROTATING View Landscape ******");
} else if(UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) {
NSLog(@"ROTATING View Portrait ******");
}
}
Run Code Online (Sandbox Code Playgroud)
}
设备和界面方向似乎是不同的东西.我在Apple的网站上找到了使用UIDeviceOrientation完成此操作的方法.使用此测试,当我旋转模拟器和我的ipad设备时,我得到了正确的触发器.
UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
if (UIDeviceOrientationIsLandscape(deviceOrientation))
{
}
else if (deviceOrientation == UIDeviceOrientationPortrait)
{
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9026 次 |
| 最近记录: |