首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

ios5跟ios6横竖屏支持及ipad和iphone设备的判断

2013-09-09 
ios5和ios6横竖屏支持及ipad和iphone设备的判断ios5和ios6横竖屏支持及ipad和iphone设备的判断判断是ipad

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;

}


这样就能控制不同方向的任何操作和界面布局了。


热点排行