我在 iPhone 的代码集中有一个通用应用程序和子视图的框架,我看到将 iPad 模拟器放置的子视图大小相同。因此 iPad 我必须重写所有框架或是否有快捷方式?这是代码。
-(void) layoutPortrait {
self.imageView= [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bar_V.png"]];
self.imageView.frame= CGRectMake(0, 0, 320, 80);
self.labelTitle.frame =CGRectMake(14, 103, 91, 54);
self.buttonFavorites.frame= CGRectMake(109, 485, 33, 33);
self.buttonHome.frame =CGRectMake(14, 485, 33, 33);
self.buttonMap.frame=CGRectMake(61, 485, 33, 33);
}
-(void) layoutLandscape {
self. imageView= [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bar_O.png"]];
self.imageView.frame= CGRectMake(0,0,568,65 );
self.labelTitle.frame =CGRectMake(20,92,165,48);
self.buttonFavorites.frame= CGRectMake(107,237,33,33);
self.buttonHome.frame =CGRectMake(11,237,33,33);
self.buttonMap.frame=CGRectMake(59,237,33,33);
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationController.navigationBar.hidden=YES;
// Do any additional setup after loading the view from its nib.
//orientazioni
UIInterfaceOrientation deviceOrientation= self.interfaceOrientation;
if(deviceOrientation == UIInterfaceOrientationPortrait || deviceOrientation== UIInterfaceOrientationPortraitUpsideDown) {
[self layoutPortrait];
}
else if (deviceOrientation== UIInterfaceOrientationLandscapeRight){
[self layoutLandscape];
}
else if (deviceOrientation==UIInterfaceOrientationLandscapeLeft){
[self layoutLandscape];
}
[self.view addSubview:self.labelTitle];
[self.view addSubview:self.imageView];
[self.view addSubview:self.buttonFavorites];
[self.view addSubview:self.buttonHome];
[self.view addSubview:self.buttonMap];
}