Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iphone 4和iphone 5的兼容性问题_Iphone_Ios_Objective C - Fatal编程技术网

iphone 4和iphone 5的兼容性问题

iphone 4和iphone 5的兼容性问题,iphone,ios,objective-c,Iphone,Ios,Objective C,我正在为iphone开发一个应用程序。我正在使用xib设计屏幕。如何为iPhone 5和iPhone 4s制作此应用程序。请帮我举个例子回答这个问题 谢谢您需要两个设计两个xib文件,一个是3.5英寸视网膜(iphone 4),另一个是4英寸视网膜(iphone 5),当您调用该xib时,您需要检查状态 #define isiPhone5 ([[UIScreen mainScreen] bounds].size.height == 568)?TRUE:FALSE #define isiPhon

我正在为iphone开发一个应用程序。我正在使用xib设计屏幕。如何为iPhone 5和iPhone 4s制作此应用程序。请帮我举个例子回答这个问题


谢谢

您需要两个设计两个xib文件,一个是3.5英寸视网膜(iphone 4),另一个是4英寸视网膜(iphone 5),当您调用该xib时,您需要检查状态

#define isiPhone5  ([[UIScreen mainScreen] bounds].size.height == 568)?TRUE:FALSE
#define isiPhone4  ([[UIScreen mainScreen] bounds].size.height == 480)?TRUE:FALSE
在constant.h文件中定义上述状态

然后在按下或更改viewcontroller时,检查视图控制器中的以下条件

if (isiPhone5) // check wheather a phone is iphone 5 or not
{

    yourViewController *objyourViewController=[[yourViewController   alloc]initWithNibName:@"yourViewController_iphone5" bundle:nil];
    [self.navigationController pushViewController:objyourViewController animated:YES];
}
else if (isiPhone4) // check wheather a phone is iphone 4 or not
{
    yourViewController *objyourViewController=[[yourViewController alloc]initWithNibName:@"yourViewController_iphone4" bundle:nil];
    [self.navigationController pushViewController:objyourViewController animated:YES];
}
我希望这将有助于您登记Xib


只有上半部分和左半部分启用..然后尝试..

对于不同分辨率的设备,有三种UI调整方法

1) -------------------------------------第一种方法-------------------------------------------

-(int)setScreenOf
    {   
        if([self isPad])
        {
            //return value 
            //code for ipad
        }
        else
        {        
            CGRect screenBounds = [[UIScreen mainScreen] bounds];
            if (screenBounds.size.height ==568) //height can be dynamic as per device
            {
                 //return value
                // code for 4-inch screen           
            }
            else
            {    //return value
                // code for 3.5-inch screen           
            }  
        }

    }
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define isiPhone5  ([[UIScreen mainScreen] bounds].size.height == 568)?TRUE:FALSE

you can make different xib for different device and navigate app according to that.

    if(IS_IPAD)
        { 
            startVc=[[Start alloc]initWithNibName:@"start_ipad" bundle:nil];
            //xib For ipad
        }
        else
        {
            if(isiPhone5 )
            {
                startVc=[[Start alloc]initWithNibName:@"start_iphone" bundle:nil];
                //xib for iphone5
            }
            else
            {
                startVc=[[Start alloc]initWithNibName:@"Start" bundle:nil]; 
                //xib for 3.5 inch device
            }

        }

nav=[[UINavigationController alloc]initWithRootViewController:startVc];
2) 第二种方法-------------------------

-(int)setScreenOf
    {   
        if([self isPad])
        {
            //return value 
            //code for ipad
        }
        else
        {        
            CGRect screenBounds = [[UIScreen mainScreen] bounds];
            if (screenBounds.size.height ==568) //height can be dynamic as per device
            {
                 //return value
                // code for 4-inch screen           
            }
            else
            {    //return value
                // code for 3.5-inch screen           
            }  
        }

    }
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define isiPhone5  ([[UIScreen mainScreen] bounds].size.height == 568)?TRUE:FALSE

you can make different xib for different device and navigate app according to that.

    if(IS_IPAD)
        { 
            startVc=[[Start alloc]initWithNibName:@"start_ipad" bundle:nil];
            //xib For ipad
        }
        else
        {
            if(isiPhone5 )
            {
                startVc=[[Start alloc]initWithNibName:@"start_iphone" bundle:nil];
                //xib for iphone5
            }
            else
            {
                startVc=[[Start alloc]initWithNibName:@"Start" bundle:nil]; 
                //xib for 3.5 inch device
            }

        }

nav=[[UINavigationController alloc]initWithRootViewController:startVc];
3) 第三种方法-----------------

-(int)setScreenOf
    {   
        if([self isPad])
        {
            //return value 
            //code for ipad
        }
        else
        {        
            CGRect screenBounds = [[UIScreen mainScreen] bounds];
            if (screenBounds.size.height ==568) //height can be dynamic as per device
            {
                 //return value
                // code for 4-inch screen           
            }
            else
            {    //return value
                // code for 3.5-inch screen           
            }  
        }

    }
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define isiPhone5  ([[UIScreen mainScreen] bounds].size.height == 568)?TRUE:FALSE

you can make different xib for different device and navigate app according to that.

    if(IS_IPAD)
        { 
            startVc=[[Start alloc]initWithNibName:@"start_ipad" bundle:nil];
            //xib For ipad
        }
        else
        {
            if(isiPhone5 )
            {
                startVc=[[Start alloc]initWithNibName:@"start_iphone" bundle:nil];
                //xib for iphone5
            }
            else
            {
                startVc=[[Start alloc]initWithNibName:@"Start" bundle:nil]; 
                //xib for 3.5 inch device
            }

        }

nav=[[UINavigationController alloc]initWithRootViewController:startVc];
您可以为不同的设备使用单一xib,但如果您的ui包含太多图像,则管理起来会变得复杂

您可以使用此授权属性调整UI控件或重新调整控件的大小。 UI控件将如何生效将通过其旁边的示例窗口显示

  • 内部箭头将使您的UI控件根据设备大小而有所不同 决议
  • 外部边界将在特定的时间限制您的控制 中央拐角处

  • Ipad标签在这里做什么???你的问题似乎没有问过与Ipad相关的问题?可能是Hi Maul的复制品,我必须在类或Appdelegate方法中声明这件事。在您完成所有导入语句后,在类中声明。如果您在控制器中添加Appdelegate.h,这将仍然可以使用上面的define语句,您必须在您必须创建的常量.h文件中包含该语句,以便您可以在您的所有类中使用它,下面的条件是你必须检查你在哪里执行按钮点击等操作。只需将其声明为.pch文件,你就可以在整个项目中使用它。