我已将苹果推送通知嵌入到我的应用程序中。弹出通知时,出现警报视图,单击视图时,导航到“详细信息”控制器。但是,单击查看按钮后,它什么也不做,并且冻结了应用程序。这是我的代码,用于在警报视图单击中打开详细信息:

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
DetailsViewController *list = [[DetailsViewController alloc]initWithNibName:@"Details" bundle:nil];

RearTableViewController *rearView = [[RearTableViewController alloc] init];
UINavigationController *frontNavigationController = [[UINavigationController alloc] initWithRootViewController:list];
UINavigationController *rearNavigationController = [[UINavigationController alloc] initWithRootViewController:rearView];

SWRevealViewController *mainRevealController = [[SWRevealViewController alloc]
                                                initWithRearViewController:rearNavigationController frontViewController:frontNavigationController];

mainRevealController.delegate = self;
[self.window.rootViewController presentViewController:mainRevealController animated:YES completion:nil];
[self.window makeKeyAndVisible];


提前致谢!

最佳答案

//Don't realloc self.window.
//self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
DetailsViewController *list = [[DetailsViewController alloc]initWithNibName:@"Details" bundle:nil];


//Alloc this VC with nib name like initWithNibNamed:bundle:
RearTableViewController *rearView = [[RearTableViewController alloc]initWithNibName:@"RearTableViewController" bundle:nil];
    UINavigationController *frontNavigationController = [[UINavigationController alloc] initWithRootViewController:list];
UINavigationController *rearNavigationController = [[UINavigationController alloc] initWithRootViewController:rearView];

SWRevealViewController *mainRevealController = [[SWRevealViewController alloc]
                                                initWithRearViewController:rearNavigationController frontViewController:frontNavigationController];

mainRevealController.delegate = self;
if(self.window.rootViewController){
      [self.window.rootViewController presentViewController:mainRevealController animated:YES completion:nil];
}
else{
     self.window.rootViewController = mainRevealController;
}
  [self.window makeKeyAndVisible];


希望它能工作。

关于ios - Apple Push Notification的App Delegate调用不显示ViewController,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31238313/

10-08 21:06