任何人都可以解释我如何使用自动布局或编程方式在iOS 7 iPad中支持横向和纵向方向 .
我已经尝试用@“将旋转方法”以编程方式和自动布局..但这两个都没有正常工作 .
不知道我在哪里弄错了
请检查以下代码以供参考并纠正我
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
NSLog(@"Landscape left");
NSLog(@"Landscape left : %@",LoginBackgroundView);
LoginViewObj.loginBackgroundImage.frame= CGRectMake(0 , 0, 1024, 768);
LoginViewObj.LoginBackgroundView.frame =CGRectMake(346, 228, 337, 300);
} else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
NSLog(@"Landscape right");
LoginViewObj.loginBackgroundImage.frame= CGRectMake(0 , 0, 1024, 768);
LoginViewObj.LoginBackgroundView.frame =CGRectMake(346, 228, 337, 300);
} else if (toInterfaceOrientation == UIInterfaceOrientationPortrait) {
NSLog(@"Portrait");
NSLog(@"potrait : %@",LoginBackgroundView);
LoginViewObj.loginBackgroundImage.frame= CGRectMake(0 , 0, 768, 1024);
LoginViewObj.LoginBackgroundView.frame =CGRectMake(0, 330, 337, 300);
} else if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
NSLog(@"Upside down");
LoginViewObj.loginBackgroundImage.frame= CGRectMake(0 , 0, 768, 1024);
LoginViewObj.LoginBackgroundView.frame =CGRectMake(0, 330, 337, 300);
}
}
2 回答
(旧方法)支持<= iOs 5上的所有接口方向..将它放在viewController中
(当前方式)支持> = iOs 6上的所有接口方向..将它们放在viewController中,并在目标设置的“常规”(第一个)选项卡中选择支持的方向...
如果你一直瞄准iOs5,那么你可以同时拥有这两个 .
得到了解决方案
}
现在,控件在两个方向上都能正常工作