私はユニバーサルアプリケーションを実装しています。次のように 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];
修正方法を教えてください。