1

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

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];
4

2 回答 2

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;

享受编码..

于 2013-03-21T10:43:05.933 回答
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] ;
于 2013-03-21T10:47:47.367 回答