2013-05-28 45 views
2

我正在开发一个应用程序在该应用程序显示20阵列图像到图像视图水平滚动。Imageview不显示适合Iphone 5 Retina

给予滚动视图到imageview的这样

scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)]; 
for (m = 0; m <=19; m++) 
    { 
     rnd = arc4random_uniform(arr.count); 

     NSString *imageName=[FrontsCards objectAtIndex:rnd]; 

    fullImageName=[NSString stringWithFormat:@"%@",imageName]; 

     int padding=0; 

     CGRect imageViewFrame=CGRectMake(scrollView.frame.size.width*m+padding, scrollView.frame.origin.y, scrollView.frame.size.width-2*padding, scrollView.frame.size.height); 

     ImgView=[[UIImageView alloc]initWithFrame:imageViewFrame]; 


     [ImgView setImage:[UIImage imageNamed:fullImageName]]; 

     [scrollView addSubview:ImgView]; 
    } 

此ImageView的正常显示为iphone 5模拟器的图像。低于黑边添加。 我该如何解决该问题?如何将该黑色边缘移除以适应Iphone 5模拟器的图像。

如何可以管理我的ImageView到iPhone 4或iPhone 5

回答

2

iPhone 5的尺寸是568和iPhone 4的尺寸是480

scrollView=[[UIScrollView alloc]init]; 

if ([[UIScreen mainScreen] bounds].size.height == 568) 
{ 

    // For Iphone5 
scrollView.frame = CGRectMake(0, 0, 320, 568) 
} 
else if ([[UIScreen mainScreen] bounds].size.height == 480) 
{ 
    //For Iphone 4 or others 
scrollView.frame = CGCGRectMake(0, 0, 320, 480) 
} 

这将真正帮助你。

+0

非常感谢... – Vasu

+0

开心编码... – Jitendra

0

尝试这个

scrollView=[[UIScrollView alloc]init]; 

if ([[UIScreen mainScreen] bounds].size.height == 568) scrollView.frame = CGRectMake(0, 0, 320, 568) 
else if ([[UIScreen mainScreen] bounds].size.height == 480) scrollView.frame = CGRectMake(0, 0, 320, 480) 

所以,它会帮助你在与iPhone 5屏幕滚动型补过。

希望它能适合你。

谢谢。

0

您需要创建为iPhone 4设计和iPhone 5的

创建一个类,这使得它其iPhone连接决定,并 化妆功能,接受的CGRect并返回的CGRect

所需大小

你可以通过

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) 
    { 
     CGSize result = [[UIScreen mainScreen] bounds].size; 
     if (result.height < 500) 
     { 
      currentDeviceHeight=460; 
      //You can use use iPhone 4 image 

     } 
     else 
     { 
      currentDeviceHeight=548; 
      // here you can use iPhone 5 image 
     } 
    } 
    else 
    { 
     // iPad 
    } 
2

iPhone 5的屏幕尺寸得到器件尺寸是568和你有过codded高度480所以它不工作的iphone5。 DO以下

scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320, [[UIScreen mainScreen] bounds].size.height)]; 

根据色器件滚动视图的高度将发生变化。

0
scrollView=[[UIScrollView alloc]initWithFrame:[[UIScreen mainScreen]bounds]]; 

使用这个方法,使UIScrollView动态

0

使用宏来检查它是否是iPhone 5或没有。

#define IS_IPHONE ([[[UIDevice currentDevice] model] isEqualToString:@"iPhone"] | [[[UIDevice currentDevice] model] isEqualToString:@"iPhone Simulator"]) 
#define IS_HEIGHT_GTE_568 [[UIScreen mainScreen ] bounds].size.height >= 568.0f 
#define IS_IPHONE_5 (IS_IPHONE && IS_HEIGHT_GTE_568) 

scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320, IS_IPHONE_5?568:480)];