我创建了一个背景颜色为红色的 UIViewController 类。我还创建了一个 UIView,它是一个子视图,并在其上放置了一个背景图像和两个 UIButton。我为屏幕方向提供的编码是
-(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 文件。我已经以编程方式创建了项目。请回复....