我有一个项目,我的VC嵌入在MMDrawerController中。 问题我的appdelegate收到了推送通知,但我不知道如何打开我收到通知的特定屏幕。将VC作为centerVC是行不通的。它在我的情况下没用,因为有些屏幕有后退按钮。 我还使用了
[_drawerController.centerViewController.navigationController pushViewController:pushedVC animated :true]
但它无用它对屏幕没有任何影响。 提前感谢任何帮助。
以下是我在AppDelegate中使用的代码,用于访问ChatVC
-(void)GotoChatVCNotification{
UIColor *navBarColor = [UIColor colorWithRed:52.0/255.0 green:56.0/255.0 blue:52.0/255.0 alpha:1.0];
[[UINavigationBar appearance] setBarTintColor:navBarColor];
NSDictionary *titleDict = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName, nil];
[[UINavigationBar appearance] setTitleTextAttributes:titleDict];
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
ChatVC *centerViewController = [storyBoard instantiateViewControllerWithIdentifier:@"ChatVC"];
centerViewController.User_id = [APPDELEGATE.userDetailsDic objectForKey:@"user_id"];
_otherUserID=[self.dicPushData valueForKey:@"sender_id"];
centerViewController.Reciever_id = [self.dicPushData valueForKey:@"sender_id"];
centerViewController.strFrom=@"notification";
centerViewController.strFriendId = [self.dicPushData valueForKey:@"sender_id"];
centerViewController.strProjectId = [self.dicPushData valueForKey:@"project_id"];
centerViewController.strChatUserName = [self.dicPushData valueForKey:@"full_name"];
centerViewController.strSupportChat = @"Chat";
[[APPDELEGATE.sideController.centerViewController navigationController] popToRootViewControllerAnimated:false];
[[APPDELEGATE.sideController.centerViewController navigationController] pushViewController:centerViewController animated:false];
//我也使用了以下这一行,我可以在该屏幕上重定向,但我的MMDrawerController的虚构性不存在。 // [[self topMostController] presentViewController:centerViewController animated:NO completion:nil];}
答案 0 :(得分:0)
您可以通过以下方式尝试。
如果您位于MMDrawerController's
centerViewController
之上的其他屏幕上,则可以尝试以下操作:
// Assuming you have access to _drawerController
// The below line is to remove any UIViewController on top of center
[[_drawerController.centerViewController navigationController] popToRootViewControllerAnimated:false];
// _screenToBeRedirectedTo is the UIViewController you want to be redirected to
[[_drawerController.centerViewController navigationController] pushViewController:_screenToBeRedirectedTo animated:false];
以上代码假设您不希望任何其他信息重定向到_screenToBeRedirectedTo
屏幕
修改强>
如果您可以指定约束,我可以给出更详细的答案。如果您有任何疑问,请随时发表评论:)