ios5和ios6横竖屏支持及ipad和iphone设备的判断
ios5和ios6横竖屏支持及ipad和iphone设备的判断
判断是ipad还是iphone设备。此定义在PayViewControllerDemo-Prefix.pch
定义如下:
@interfaceViewController ()
{之后需要在top-most controller中来控制方向问题。
if ([[UIDevicecurrentDevice]systemVersion].floatValue >= 6.0)
{
//判断设备当前的方向,然后重新布局不同方向的操作。
UIInterfaceOrientation currentOrientation = [[UIApplicationsharedApplication] statusBarOrientation];
if (currentOrientation ==UIInterfaceOrientationPortrait || currentOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
if (isPad ==iPad)
{
drawViewipad.frame =CGRectMake(200, 150, 412, 120);
consumeBtnipd.frame =CGRectMake(768/2-280/2,550, 280, 50);
}
else if (isPad ==iPhone)
{
drawViewihone.frame =CGRectMake(85, 50,170, 60);
consumeBtnipone.frame =CGRectMake(90, 200,140, 40);
}
}
if (currentOrientation ==UIInterfaceOrientationLandscapeLeft || currentOrientation ==UIInterfaceOrientationLandscapeRight)
{
if (isPad ==iPad)
{
drawViewipad.frame =CGRectMake(306, 150, 412, 120);
consumeBtnipd.frame =CGRectMake(1024/2-280/2,550, 280, 50);
}
else if (isPad ==iPhone)
{
drawViewihone.frame =CGRectMake(155, 50, 170, 60);
consumeBtnipone.frame =CGRectMake(170, 200, 140, 40);
}
}
}
returnUIInterfaceOrientationMaskAll;
}
这样就能控制不同方向的任何操作和界面布局了。