从子视图中使用presentModalViewController

发布于 2024-11-30 13:21:20 字数 369 浏览 3 评论 0原文

我想使用子视图中的 presentModalViewController 方法,但它对我不起作用 这是我的代码:

子视图:

-(IBAction) PressMoyensEs {
    MoyensEstimatifsViewController *MoyE = [[MoyensEstimatifsViewController alloc] initWithNibName:@"MoyensEstimatifsViewController" bundle:nil];
    [self.parentViewController presentModalViewController:MoyE animated:YES];
}

I wanna use the presentModalViewController method from a subview, but it's not working for me
here is my code:

The subview:

-(IBAction) PressMoyensEs {
    MoyensEstimatifsViewController *MoyE = [[MoyensEstimatifsViewController alloc] initWithNibName:@"MoyensEstimatifsViewController" bundle:nil];
    [self.parentViewController presentModalViewController:MoyE animated:YES];
}

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

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

发布评论

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

评论(1

天荒地未老 2024-12-07 13:21:20

你检查过你的 self.parentViewController 了吗?它很可能是nil,就像在许多情况下一样,因此您的代码会默默地失败。

而且,您是否尝试过 [selfpresentModalViewController:MoyEanimated:YES]; ?它不太“正确”,但如果有效,就已经排除了一些失败原因。

Have you checked your self.parentViewController? It's likely to be nil, as it is in many case, and thus your code is failing silently.

And, have you tried just [self presentModalViewController:MoyE animated:YES];? It's less 'correct', but if working, would already exclude some causes of failure.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文