Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/36.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
iphone5优化_Iphone_Objective C_Xcode - Fatal编程技术网

iphone5优化

iphone5优化,iphone,objective-c,xcode,Iphone,Objective C,Xcode,我在“viewDidLoad”中使用此代码检查应用程序是否在iPhone 5或普通iPhone上运行 if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { CGSize result = [[UIScreen mainScreen] bounds].size; if(result.height == 480) { // iPhone Classic [_backgr se

我在“viewDidLoad”中使用此代码检查应用程序是否在iPhone 5或普通iPhone上运行

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
    CGSize result = [[UIScreen mainScreen] bounds].size;
    if(result.height == 480)
    {
        // iPhone Classic

        [_backgr setImage:[UIImage imageNamed:@"usefull_i4.png"]];
        [scrollView setFrame:CGRectMake(16, 69, 291, 349)];
        [_backgr setFrame:CGRectMake(0, 0, 320, 480)];


    }
    if(result.height == 568)
    {
        // iPhone 5
        [_backgr setImage:[UIImage imageNamed:@"usefull_i5.png"]];
        [scrollView setFrame:CGRectMake(15, 111, 295, 349)];
        [_backgr setFrame:CGRectMake(0, 0, 320, 568)];

    }
}
它不起作用(只有当我改变了!这里从iPhone3.5到iPhone4,这段代码才有效

我还将此代码用于另一个ViewController,效果非常好。我不使用自动布局。

尝试此宏:(在.pch文件中)


不工作..它会拉伸图像..正是这段代码在另一个viewcontrollerThanks中对同一项目有效。我修复了。问题在于自动调整UIImageView的大小。
#define IS_IPHONE_5 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
    if(IS_IPHONE_5)
    {
         // code
    }
}