我如何检查我当前的navigationController.view是否是一个classes.view?Reason =推送通知.+ iphone

Ken*_*eth 4 iphone apple-push-notifications

所以基本上在我的app委托中我有一个navigation.controller

此导航控制器具有名为MainScreen的类的视图.

在MainScreen.m中,我有一个IBAction,通过推送它将我带到SelectionScreen.m页面.这是它的编码

SelectionScreen *aSelectionScreenViewController = [[SelectionScreen alloc]initWithNibName:@"SelectionScreen" bundle:nil];
[self.navigationController pushViewController:aSelectionScreenViewController animated:YES];
[aSelectionScreenViewController release];
Run Code Online (Sandbox Code Playgroud)

那么我该如何检查我当前的navigationController.view =这个selectionscreen.view?

检查当前视图的原因是因为当我收到推送通知时,我想自动切换到此SelectionScreen.m页面并调用其中的一些方法.但是这个检查只能在appDelegate中完成,因为didReceiveRemoteNotification方法位于那里.

X S*_*ham 8

这就是我在做的方式

例如,如果您有三个ViewControllers,并且其中任何一个都可能被NavigationController推送:

ViewControllerA
ViewControllerB
ViewControllerC
Run Code Online (Sandbox Code Playgroud)

然后你需要做的是:

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
    if ([[self.navigationController topViewController] isKindOfClass:[ViewControllerA class]]) {

    //do sth
    }

    if ([[self.navigationController topViewController] isKindOfClass:[ViewControllerB class]]) {

    //do sth
    }

    if ([[self.navigationController topViewController] isKindOfClass:[ViewControllerC class]]) {

    //do sth
    }

}//end of code
Run Code Online (Sandbox Code Playgroud)