非同期 HTTP リクエストを実行するときは、iPhone のステータス バーを非表示にし、独自のカスタム UIViewController でアニメーション化してアップロード ステータスを表示します。したがって、ユーザーは、信号強度、キャリア、時間、およびバッテリー寿命を確認する代わりに、HTTP 要求の進行状況に基づいてメッセージを取得します。私のステータス バーの高さはちょうど 20px で、ステータス バーがあった場所にうまく収まります。HTTP アクティビティが完了すると、カスタム ビューがアニメーション表示され、iPhone ステータス バーがアニメーション表示されます。
iPhone のステータス バーを完全に非表示にすることは避け、代わりにカスタム ビューをステータス バーの一番上に表示したいと思います。現在、カスタム ビュー アニメーションを呼び出して iPhone のステータス バーを表示したままにしておくと、カスタム ビューが背後に表示されます。
これは私が持っているコードです:
-(void) animateStatusBarIn {
CGRect statusFrame = CGRectMake(0.0f, -20.0f, 320.0f, 20.0f);
UploadStatusBar *statusView = [[UploadStatusBar alloc] initWithNibName:@"UploadStatusBar" bundle:nil];
self.status = statusView;
[statusView release];
status.view.frame = statusFrame;
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
[window addSubview:status.view];
[UIView beginAnimations:@"slideDown" context:nil];
[UIView setAnimationDuration:0.3];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationFinished:)];
status.view.frame = CGRectMake(0.0f, 0.0f, 320.0f, 20.0f);
[UIView commitAnimations];
}
-(void) animateStatusBarOut {
[UIView beginAnimations:@"slideUp" context:nil];
[UIView setAnimationDuration:0.3];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationFinished:)];
status.view.frame = CGRectMake(0.0f, -20.0f, 320.0f, 20.0f);
[UIView commitAnimations];
}
-(void)animationFinished:(NSString *)name {
if ([name isEqualToString:@"slideDown"]) {
}
if ([name isEqualToString:@"slideUp"]) {
[[UIApplication sharedApplication]setStatusBarHidden:NO animated:YES];
[status.view removeFromSuperview];
}
}
[[UIApplication sharedApplication]setStatusBarHidden:YES animation:YES] がないと、カスタム ビューが表示されません。カスタム ビューをステータス バーの上だけに表示して非表示にする必要がないようにするにはどうすればよいですか?
ありがとうございました!