我在使用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];
答案 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] ;