Uialertview解雇返回主屏幕

发布于 2025-01-20 11:01:06 字数 1131 浏览 3 评论 0原文

我的应用程序以一个“主屏幕”导航控制器开始,该导航控制器位于自己的故事板上,并且可以转到不同的故事板,每个故事板都以新的导航控制器开始。我的次要故事板之一有付费墙。当用户选择在不进行购买的情况下解雇付费墙时,我所能完成的一切就是解雇付费墙,并显示需要购买的故事板的根视图控制器。我正在尝试将用户送回“主屏幕”,在那里他们可以看到其他内容或segue到其他故事板。

[PaywallManager registerBlockingPaywallClosedHandler:^{
  UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Blocked Paywall Closed" message:@"Return to home screen without purchase." preferredStyle:UIAlertControllerStyleAlert];
        
  UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
    [alertController dismissViewControllerAnimated:true completion:^{
    }]
  }];
  
  [alertController addAction:okAction];
  UIViewController *rootViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController];
  [rootViewController presentViewController:alertController animated:true completion:^{}];
}];

当用户通过按确定按钮来删除UialertView时,我需要回到主导航控制器(主屏幕)。当前,当用户删除UialerTview时,他们可以访问付费内容。如果我删除了封闭的处理程序,则该应用程序会卡在付费墙上,直到购买或用户杀死该应用程序为止。任何帮助将不胜感激。我仍在与Objective-C斗争,没有时间学习Swift,所以请放轻松。

My app starts with a "home screen" navigation controller that sits in its own storyboard, and can segue to different storyboards, each beginning with a new navigation controller. One of my secondary storyboards has a paywall. When the user elects to dismiss the paywall without making a purchase, all I've been able to accomplish is dismissing the paywall and displaying the root view controller of the storyboard that requires a purchase. I'm trying to send the user back to the "home screen" where they can see other content or segue to a different storyboard.

[PaywallManager registerBlockingPaywallClosedHandler:^{
  UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Blocked Paywall Closed" message:@"Return to home screen without purchase." preferredStyle:UIAlertControllerStyleAlert];
        
  UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
    [alertController dismissViewControllerAnimated:true completion:^{
    }]
  }];
  
  [alertController addAction:okAction];
  UIViewController *rootViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController];
  [rootViewController presentViewController:alertController animated:true completion:^{}];
}];

When the user dismisses the UIAlertView by pressing the OK button, I need to segue back to the main navigation controller (home screen). Currently when the user dismisses the UIAlertView, they get access to the paid content. If I remove the closed handler, the app gets stuck on the paywall until a purchase is made or the user kills the app. Any help would be greatly appreciated. I am still struggling with Objective-C and haven't had time to learn Swift so please go easy on me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

征棹 2025-01-27 11:01:06

我发现了。解决方案在这里:

    [PaywallManager registerBlockingPaywallClosedHandler:^{
      UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"No Purchase Made" message:@"Return to the Home screen without purchase." preferredStyle:UIAlertControllerStyleAlert];
            
      UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
          [self.navigationController popViewControllerAnimated:YES];
        }];
      
      [alertController addAction:okAction];
        [self presentViewController:alertController animated:YES completion:nil];
    }];

I figured it out. The solution is here:

    [PaywallManager registerBlockingPaywallClosedHandler:^{
      UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"No Purchase Made" message:@"Return to the Home screen without purchase." preferredStyle:UIAlertControllerStyleAlert];
            
      UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
          [self.navigationController popViewControllerAnimated:YES];
        }];
      
      [alertController addAction:okAction];
        [self presentViewController:alertController animated:YES completion:nil];
    }];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文