0

背景色が赤の UIViewController クラスを作成しました。また、サブビューである UIView を作成し、背景画像と 2 つの UIButtons を配置しました。画面の向きのために私が与えるコーディングは

 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}

self.view =[[UIView alloc] initWithFrame:CGRectMake(0,0,320,480)];
self.view.backgroundcolor =[UIColor redColor];
UIView *subview;
subview = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,480)];
subview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@""]];
subview.autoresizingMask = UIViewAutoResizingFlexibleWidth |UIViewAutoresizingFlexibleHeight;

問題:

横向きにすると、サブビューのサイズが画像に合わせて変更されますが、ボタンは同じ位置にあり、.xib ファイルを使用していません。プログラムでプロジェクトを作成しました。返信してください....

4

1 に答える 1

0

layoutSubviewsクラスのオーバーライド。[self setNeedsLayout]から 明示的に呼び出す必要がある場合がありますdidRotateFromInterfaceOrientation

于 2010-05-19T11:43:02.397 に答える