Iphone 如何检查当前的navigationController.view是否为classes.view?原因=推送通知+;苹果手机
因此,基本上在我的应用程序代理中,我有一个navigation.controller 此导航控制器具有名为MainScreen的类的视图 在MainScreen.m中,我有一个iAction,按下它会将我带到SelectionScreen.m页面。这是它的编码Iphone 如何检查当前的navigationController.view是否为classes.view?原因=推送通知+;苹果手机,iphone,apple-push-notifications,Iphone,Apple Push Notifications,因此,基本上在我的应用程序代理中,我有一个navigation.controller 此导航控制器具有名为MainScreen的类的视图 在MainScreen.m中,我有一个iAction,按下它会将我带到SelectionScreen.m页面。这是它的编码 SelectionScreen *aSelectionScreenViewController = [[SelectionScreen alloc]initWithNibName:@"SelectionScreen" bundle:nil
SelectionScreen *aSelectionScreenViewController = [[SelectionScreen alloc]initWithNibName:@"SelectionScreen" bundle:nil];
[self.navigationController pushViewController:aSelectionScreenViewController animated:YES];
[aSelectionScreenViewController release];
那么,如何检查我当前的navigationController.view=此选项Screen.view
检查当前视图的原因是,当我收到推送通知时,我希望自动切换到此SelectionScreen.m页面并调用其中的一些方法。但此检查只能在appDelegate中进行,因为DidReceiveMemoteNotification方法位于其中。一种方法是将selectionScreenViewController保存为应用程序委派的属性,然后:
if (self.navigationController.topViewController == self.selectionScreenViewController) {
//...
}
else {
//...
}
嘿,伙计们,我用了一种简单的方法。在我拥有的每个视图控制器中,我删除了所有对象,并将一个对象分配给appdelegate中的一个数组。这样一来,每次我进入一个新的视图,值都是不同的 因此,在AppDidReceiveMemotentification中,我可以检查该数组并决定相应的操作
这只是一种简单的检查方法 我就是这样做的 例如,如果您有三个ViewController,其中任何一个都有可能被NavigationController推送:
ViewControllerA
ViewControllerB
ViewControllerC
那么你需要做的是:
-(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
对不起,我不知道怎么做:\。