从子视图中使用presentModalViewController
我想使用子视图中的 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你检查过你的 self.parentViewController 了吗?它很可能是
nil
,就像在许多情况下一样,因此您的代码会默默地失败。而且,您是否尝试过
[selfpresentModalViewController:MoyEanimated:YES];
?它不太“正确”,但如果有效,就已经排除了一些失败原因。Have you checked your
self.parentViewController
? It's likely to benil
, 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.