画面の下部にあるツールバーに UIButton を追加するのに苦労しています。問題は、ツールバーの上に表示されず、その下に隠れていることです。
追加しようとしているツールバーのコード (および以下の [戻る] ボタンのコード) は次のとおりです。
座標は 100% ではないので無視してください。ただし、少なくとも iPhone バージョンは同じ領域の周りにあるため、ツールバーに表示される必要があります。後で正確に調整できます。
//Insert Main Toolbar On Main View
if (IS_IPHONE_5) {
//offsetY = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) ? 6 : 6 * 2;
offsetY = (1136 - 960) / 2;
frameRect = CGRectMake(0, SCREEN_HEIGHT - 53, 320 * 2, 53);
}else if (IS_IPHONE || IS_IPHONE_4) {
offsetY = 0;
frameRect = CGRectMake(0, SCREEN_HEIGHT - 53, 320 * 2, 53);
} else {
frameRect = CGRectMake(0, 1024 - 53 * 2, 768 * 2, 53 * 2);
}
offsetY = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) ? 6 : 6 * 2;
main_toolbar = [[UIImageView alloc] initWithFrame:frameRect];
[main_toolbar setImage:[UIImage imageNamed:[g_AppUtils resourceNameForDevice:@"ToolbarBackground" ofType:@"png"]]];
main_toolbar.userInteractionEnabled = YES;
[self.view addSubview:main_toolbar];
[main_toolbar release];
//Insert Go Back Button On Main Toolbar
goHome_button = [[UIButton alloc] initWithFrame:frameRect];
goHome_button = [UIButton buttonWithType:UIButtonTypeCustom];
[goHome_button setImage:[UIImage imageNamed:@"BackButton.png"] forState:UIControlStateNormal];
[goHome_button addTarget:self action:@selector(backButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
goHome_button.frame = CGRectMake(55, 410, 46, 42);
} else {
goHome_button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
}
[main_toolbar addSubview:goHome_button];
[self.view addSubview:goHome_button];