私はユニバーサルアプリケーションに取り組んでいます。1 つのビュー コントローラーを持つビュー ベースのアプリケーションがあります。UIImageView
サブビューとして aを追加しています。
私の問題は、ImageView を に配置するとviewDidLoad
、iPad でサイズが変更されることです。
しかし、ボタン タップ イベントで ImageView をビュー コントローラーに動的に追加すると、UIImageView
iPad のようにサイズが変更されません。代わりに、320 x 480 のサイズの ImageView を表示しています。
注:私のView ControllersetAutoresizesSubviews
はYES
.
私のコードは以下の通りです:
-(void)buttonTap
{
UIImage *img = [[UIImage alloc]initWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"main-bg" ofType:@"png"]];
UIImageView *imgViewMainBG = [[UIImageView alloc]initWithImage:img];
imgViewMainBG.frame = CGRectMake(0,0,320,480);
imgViewMainBG.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:imgViewMainBG];
[imgViewMainBG release];
[img release];
img=nil;
}