0
我正在開發一個響應Parse推送通知的應用程序。在應用程序的某個時候,我想按下另一個用戶發送的推送通知,這應該會將我重定向到TabBarController中的第三個ViewController(選項卡),並且我想在該選項卡中顯示一個視圖。appDelegate中的塊內調用方法
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error){
if (!error && [PFUser currentUser]) {
//Display the TabBarController
UIViewController *controller = [[UIViewController alloc] init];
controller = [storyboard instantiateViewControllerWithIdentifier:@"TabBar"];
self.window.rootViewController = controller;
[self.window makeKeyAndVisible];
//Display the third tab
self.tabBarController = (TabBarViewController *)self.window.rootViewController;
self.tabBarController.delegate = (id)self;
self.tabBarController.selectedIndex = 2;
[self.tabBarController display];
}
else{
NSLog(@"%@", error);
}
}];
我查詢差我來的通知和查詢結束後,我想在我的TabBarContoller的視圖控制器一個標籤來顯示用戶的用戶名的用戶。 (但爲了簡單起見,我只想在第三個標籤中顯示一個視圖)。
我試着在塊外執行相同的代碼行,並且它工作,但是由於某種原因,當我嘗試在塊內執行[self.tabBarController display]時,它不起作用。
我也試過:
__block TabBarViewController* blocksafeSelf = self.tabBarController;
....
....
[blocksafeSelf display];
,但它沒有工作!
我一直在尋找如何解決它的小時!任何幫助,將不勝感激。
其他試圖把一切都在我剛纔提到的塊並看看是否有效,並從那裏去 – Fonix 2014-11-22 14:48:27
謝謝你的回覆,但不幸的是它沒有工作。如果我把所有內容都放在屏幕上,應用程序就會出現黑屏並在一段時間後崩潰。我也嘗試使用[self.tabBarController performSelectorOnMainThread:@selector(display)withObject:nil waitUntilDone:NO]但沒有任何運氣。 – RB12 2014-11-23 09:33:37
我發現問題是什麼!我有一行代碼嘗試提取數組對象的第一個索引(由於某個錯誤,它始終爲零),並且出於某種原因它阻止了之後的任何行。我不知道這將是相關的添加,所以我從帖子中刪除它。 – RB12 2014-11-23 17:29:10