presentViewController不能像我一样工作(presentViewController not working as I'd like)

编程入门 行业动态 更新时间:2024-10-08 02:20:45
presentViewController不能像我一样工作(presentViewController not working as I'd like)

我有我的presentViewController代码设置如下:

ProductViewController *vc = [[ProductViewController alloc] init]; [self presentViewController:vc animated:YES completion:nil];

它确实呈现了vc控制器,但我无法点击它,它就像一个冻结的屏幕。 是因为还有一个观点吗? 或者我不应该使用alloc] init ?

ProductViewController是一个现有的视图控制器(它实际上是根视图控制器),所以基本上我只想让presentViewController返回到根视图控制器。

编辑:

我有一个ShippingViewController ,用户输入名称/运输详细信息。

然后他们点击“Checkout”按钮,显示PaymentViewController (其中有一个导航栏,所有其他View Controller都没有)。 在PaymentViewController ,用户输入他们的信用卡详细信息并点击“付款”按钮。

如果付款成功,我希望展示ProductViewController (初始/根视图控制器)。 目前,如果我只是调用dismissViewController ,它会显示ShippingViewController 。

I have my presentViewController code set up like this:

ProductViewController *vc = [[ProductViewController alloc] init]; [self presentViewController:vc animated:YES completion:nil];

It indeed presents the vc controller, but I'm unable to tap anything on it, it's like a frozen screen. Is it because there is still a view on top of it? Or I shouldn't be using alloc] init?

ProductViewController is an existing view controller (it's actually the root view controller), so basically I'd just like the presentViewController to just go back to the root view controller.

Edit:

I have a ShippingViewController where the user enters name/shipping details.

Then they tap on "Checkout" button that presents the PaymentViewController (which has a navigation bar, all other View Controllers don't). On the PaymentViewController, the user enters their credit card details and tap the "Pay" button.

If the payment is successful, I wish for ProductViewController (the initial/root view controller) to be presented. Currently if I am just calling dismissViewController, it presents ShippingViewController.

最满意答案

这似乎解决了我的问题:

NSString *storyboardName = @"Main"; UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil]; UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"id"]; [self presentViewController:vc animated:YES completion:nil];

This seemed to take care of my problem:

NSString *storyboardName = @"Main"; UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil]; UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"id"]; [self presentViewController:vc animated:YES completion:nil];

更多推荐

本文发布于:2023-07-09 10:05:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1085526.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:像我一样   工作   presentViewController   working

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!