如果从app代理提交视图控制器,如何解除它?

时间:2014-10-23 16:33:44

标签: ios objective-c

所以我试图找出深层链接。我已经成功地让我的应用程序识别并运行我希望它的代码,具体取决于URL中的路径。现在,当我呈现一个视图时,它显示但无法获得后退按钮或任何方式来解除它的工作。这是我的appdelegate中的代码:

        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
        BuyPremiumViewController *premiumViewController = [storyboard instantiateViewControllerWithIdentifier:@"BuyPremium"];
        UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:premiumViewController];
        [self.window makeKeyAndVisible];
        [self.window.rootViewController presentViewController:navigationController animated:YES completion:NULL];           

我使用UINavigationController的原因是在显示的视图中显示导航标题和后退按钮。事情是,它不起作用。以下是在显示的视图中点按后退按钮时运行的代码:

- (void)backButton {
 NSLog(@"this ran"); //check if actually ran
 [self.navigationController popToRootViewControllerAnimated:YES];
}

现在待了几个小时,帮帮忙?

1 个答案:

答案 0 :(得分:0)

尝试使用此代码:

- (void)backButton
 {
     NSLog(@"this ran"); //check if actually ran
     [self.navigationController dismissViewControllerAnimated:YES completion:nil];
 }