自从我升级到 XCODE 4.5 后,我就面临这个问题。
我有各种 UI 元素
UIButton *button1;
UIButton *button2;
UIButton *button3;
- (void)viewDidLoad
{
button1 =[[UIButton alloc]init ];
button1.backgroundColor=[UIColor yellowColor];
[self.view addSubview:button1];
button2 =[[UIButton alloc]init ];
button2.backgroundColor=[UIColor yellowColor];
[self.view addSubview:button2];
button3 =[[UIButton alloc]init ];
button3.backgroundColor=[UIColor yellowColor];
[self.view addSubview:button3];
}
其帧被声明在
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if(interfaceOrientation==UIInterfaceOrientationPortrait ||[interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown )
{
button1.frame=CGRectMake(10,10,10,10);
button2.frame=CGRectMake(10,30,10,10);
button3.frame=CGRectMake(10,50,10,10);
}
if(interfaceOrientation ==UIInterfaceOrientationLandscapeLeft ||interfaceOrientation==UIInterfaceOrientationLandscapeRight)
{
button1.frame=CGRectMake(20,10,10,10);
button2.frame=CGRectMake(20,30,10,10);
button3.frame=CGRectMake(20,50,10,10);
}
return YES;
}
但框架没有在 Xcode 4.5 中设置。在以前的版本中它工作正常。
我需要在我的应用程序中自动调整大小。所以帮助我。