我正在实现一个通用应用程序。我在 init 方法中实现了一个“UIView”,如下所示:
[self setWantsFullScreenLayout:YES];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
Menu = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 480.0)];
[Menu setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"Fond_Menu.png"]]];
}
else
{
Menu = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 768, 1024)];
[Menu setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"Fond_Menu_Ipad.png"]]];
}
[self.view addSubview:Menu];
[Menu release];
但是当我添加一个“UIButton”时,它可以在 Iphone 模拟器上运行,而不是在 Ipad 上运行。
请参阅,在“ViewDidLoad”方法中:
Jouer = [UIButton buttonWithType:UIButtonTypeCustom];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
[Jouer setFrame:CGRectMake(82.5, 240, 155, 35)];
[Jouer setImage:[UIImage imageNamed:NSLocalizedString(@"Bouton_Jouer", @"")] forState:UIControlStateNormal];
[Jouer setImage:[UIImage imageNamed:NSLocalizedString(@"Bouton_Jouer_HIGH", @"")] forState:UIControlStateHighlighted];
}
else
{
[Jouer setFrame:CGRectMake(214, 505, 340, 77)];
[Jouer setImage:[UIImage imageNamed:NSLocalizedString(@"Bouton_Jouer_Ipad", @"")] forState:UIControlStateNormal];
[Jouer setImage:[UIImage imageNamed:NSLocalizedString(@"Bouton_Jouer_HIGH_Ipad", @"")] forState:UIControlStateHighlighted];
}
[Jouer addTarget:self action:@selector(MyMethod)forControlEvents:UIControlEventTouchUpInside];
[Menu addSubview:Jouer];
请问如何解决?