0
我有一個通用的應用程序和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];
}