iphone5优化
我在“viewDidLoad”中使用此代码检查应用程序是否在iPhone 5或普通iPhone上运行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
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
}
}