我正在製作一個包含遊戲中心功能「邀請朋友」的應用程序,因此我根據Game Center編程指南進行製作。iOS:遊戲中心朋友邀請請求查看控制器更改狀態欄顏色當完成
我面臨的主要問題是解僱GKFriendRequestComposeViewController
後狀態欄顏色的變化。
在我的應用程序中,我正在使用帶狀態欄燈光風格的黑色界面。當我撥打GKFriendRequestComposeViewController
時,狀態欄顏色會更改爲默認值(例如黑色)。 當我通過GKFriendRequestComposeViewController
完成我的操作 - 取消或發送邀請時,View Controller將刪除狀態欄顏色,將其變化動畫化爲白色,然後立即變回黑色。
我無法改變這種行爲。這裏是我的代碼:
代碼顯示GKFriendRequestComposeViewController
:
- (void) inviteFriends
{
GKFriendRequestComposeViewController *friendRequestViewController = [[GKFriendRequestComposeViewController alloc] init];
friendRequestViewController.composeViewDelegate = self;
[friendRequestViewController addRecipientsWithPlayerIDs: nil];
[self presentViewController:friendRequestViewController animated:YES completion:nil];
}
就像在編程指南。
代碼去除GKFriendRequestComposeViewController
:
- (void)friendRequestComposeViewControllerDidFinish:(GKFriendRequestComposeViewController *)viewController
{
[self.presentingViewController dismissViewControllerAnimated:YES completion:^{
NSLog(@"this code is never execute");
}];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}
這裏是我面臨的一些問題。第一:如果我使用的self
代替self.presentingViewController
我收到此錯誤:
Warning: Attempt to dismiss from view controller <UINavigationController: 0x16d45310> while a presentation or dismiss is in progress!
所以,我用self.presentedViewController。但是完成塊不會被調用。爲什麼?
我的代碼不會改變這裏的狀態欄的風格,但我在其他應用程序部分採用
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
,它工作正常。
順便說一句,myApp-Info.plist
包含此設置:
- 狀態欄最初是隱藏 - NO
- 狀態欄樣式 - UIStatusBarStyleLightContent
- 查看基於控制器的狀態欄外觀 - NO
請幫我解決這個問題。謝謝。
對不起,我遇到了同樣的問題,做u如何解決呢 – passol
@passol現在我拋開這個麻煩,後來我決定在每個屏幕上手動控制狀態欄,因爲我的應用程序中有顏色變化。 –
@passol你好,我回到了我的煩惱,如果你解決了它,請寫一個答案。 –