【发布时间】:2014-11-22 14:35:20
【问题描述】:
我正在开发一个响应 Parse 推送通知的应用程序。在应用程序的某个时刻,我想按下另一个用户发送的推送通知,这应该将我重定向到 TabBarController 中的第三个 ViewController(选项卡),并且我想在该选项卡中显示一个视图。
[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 的 ViewController 中的标签中显示用户的用户名。 (但为了简单起见,我现在只想在第三个选项卡中显示一个视图)。
我尝试在块外执行相同的代码行并且它可以工作,但是由于某种原因,当我尝试在块内执行 [self.tabBarController display] 时,它不起作用。
我也试过了:
__block TabBarViewController* blocksafeSelf = self.tabBarController;
....
....
[blocksafeSelf display];
但它没有用!
我一直在寻找如何解决它的几个小时!任何帮助将不胜感激。
【问题讨论】:
标签: objective-c parse-platform objective-c-blocks