私の目標は、iPhone アプリ (寸法 320*20 ピクセル) の上部にあるステータス バーの上に非表示のボタンを描画することです。
何を試しても、何かバグがあります:
たとえば、新しいビューを作成しようとしました。ビューをアプリの一番上に配置したい場合、ステータスバーの前ではなく、常にステータスバーの後ろに消えます!
Stackoverflow で別の素晴らしいアイデアを見つけました: StatusBar を含む他のすべてのビューの上に UIView を追加 する 2 つ目の UIWindow が推奨されていなくても、実装しようとしました。問題に気付くまでは、思い通りに機能していました。必要なときにキーボードが表示されなくなったのです (たとえば、テキスト ボックスをクリックしたときなど)。
どうすればこれを修正できますか? または、私の問題に対するより良いアプローチがありますか? これは、2 番目のウィンドウを作成するための私のコードです。
// Create window
statusWindow = [[UIWindow alloc] initWithFrame:CGRectMake(0,0,320,20)];
statusWindow.windowLevel = UIWindowLevelStatusBar;
[statusWindow makeKeyAndVisible];
// Create statusBarButton
statusBarButton = [UIButton buttonWithType:UIButtonTypeCustom];
CGRect buttonFrame2 = statusBarButton.frame;
buttonFrame2.size = CGSizeMake(320,20);
statusBarButton.frame = buttonFrame2;
[statusBarButton addTarget:self action:@selector(goTop) forControlEvents:UIControlEventTouchUpInside];
// Place button into the new window
[statusWindow addSubview:statusBarButton];