解释一下不同iOS设备中的自动调整大小问题?

时间:2013-03-21 10:27:20

标签: iphone ios

我在使用CGRectMake的iPhone应用开发中遇到自动调整大小的问题。谁能解释一下呢?

CGRect imgframe=CGRectMake(0, 0, 320, 283);
UIImageView *imgview=[[UIImageView alloc]initWithFrame:imgframe];
 KMAppDelegate *app=(KMAppDelegate *)[[UIApplication sharedApplication]delegate];
 [imgview setAutoresizingMask:UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleHeight];
imgview.image=[UIImage imageNamed:app.imgString];

2 个答案:

答案 0 :(得分:1)

你试试这个代码......可能对你有帮助..

    imgview =[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 283)];
    KMAppDelegate *app=(KMAppDelegate *)[[UIApplication sharedApplication]delegate];
 [imgview setAutoresizingMask:UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleHeight];
imgview.image=[UIImage imageNamed:app.imgString];
    imgview.contentMode = UIViewContentModeScaleAspectFit;

享受编码..

答案 1 :(得分:0)

  CGRect imgframe=CGRectMake(0, 0, 320, 283);
    UIImageView *imgview=[[UIImageView alloc]initWithFrame:imgframe];
    KMAppDelegate *app=(KMAppDelegate *)[[UIApplication sharedApplication]delegate];
    [imgview setAutoresizingMask:UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleHeight];
    imgview.image=[UIImage imageNamed:app.imgString];
    imgview.contentMode = UIViewContentModeScaleAspectFit;
    [[self view] addSubview:imgview] ;