Cocoa Touch-dismissModalViewControllerAnimated:YES 不起作用

发布于 2024-12-05 07:24:21 字数 393 浏览 0 评论 0原文

大家好,

可能这是一个相当简单的问题,但我是新手,无法解决它。好吧,问题是:

  1. 我有主视图控制器,在该控制器的 viewdidAppear 委托中,我使用 [selfpresentModalViewControlleranimated:YES]; 来显示我的第二个视图。
  2. 在我的第二个视图控制器中的方法之一中,它为特定进程启动了第三个控制器。
  3. 第三控制器中的处理结束后,再次发起第二控制器来调用第二控制器中的方法。在此方法中,我使用 [selfmissModalViewControllerAnimated:YES]; 但第二个视图拒绝关闭。

希望我对我的场景足够清楚。请指教。提前致谢!

:)

Hihi all,

Probably this is a fairly simple question, but I am new and just couldn't get it resolved. Okay, here is the problem:

  1. I have main view controller, in this controller's viewdidAppear delegate, I use [self presentModalViewController animated:YES]; to show my second view.
  2. In one of the method in my second view controller, it initiated the third controller for certain process.
  3. After the process in the third controller, it initiates again the second controller to call a method in the second controller. In this method, I use [self dismissModalViewControllerAnimated:YES]; but the second view just refuses to dismiss.

Hope I am clear enough on my scenario. Please advice. Thanks in advance!

:)

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

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

发布评论

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

评论(2

诗化ㄋ丶相逢 2024-12-12 07:24:21

@来自帖子:在第三个控制器中的过程之后,它再次启动第二个控制器来调用第二个控制器中的方法。

这表明您正在启动 secondaryViewController 的新实例,其中没有 modalViewController 。您应该为实际呈现它的实例调用dismissModalViewControllerAnimated。

像下面

这样设计你的thirdViewController并且

@class SecondView;
@interface ThirdView : UIViewController {
    SecondView *secondViewRefPointer;

}
@property (nonatomic, retain) SecondView * secondViewRefPointer;
@end

......

//While adding the third view from the secondView
ThirdView *thirdViewInstance = [[ThirdView alloc]init];
thirdViewInstance.secondViewRefPointer = self; //self will refer to the current secondView instance

第三个视图中调用dismissModalViewController,如下所示

[secondViewRefPointer dismissModalViewControllerAnimated:YES];

@from the post:After the process in the third controller, it initiates again the second controller to call a method in the second controller.

This shows that you are initiating a new instance of secondViewController which don't have a modalViewController presented in it. You should call the dismissModalViewControllerAnimated for the instance in which you actually presented it.

Like below

Design your thirdViewController like this

@class SecondView;
@interface ThirdView : UIViewController {
    SecondView *secondViewRefPointer;

}
@property (nonatomic, retain) SecondView * secondViewRefPointer;
@end

and

//While adding the third view from the secondView
ThirdView *thirdViewInstance = [[ThirdView alloc]init];
thirdViewInstance.secondViewRefPointer = self; //self will refer to the current secondView instance

And in third view call the dismissModalViewController as below

[secondViewRefPointer dismissModalViewControllerAnimated:YES];
烙印 2024-12-12 07:24:21

作为点击和试用,只需首先尝试通过第三个视图中的任何按钮触发操作来调用dismissModalViewControllerAnimated:YES。如果这有效,请使用 NSLog 并检查调用方法的顺序。这样你就可以弄清楚你应该把你的missModalViewControllerAnimated:YES放在哪里。

希望这有帮助。

As a hit and trial, just try first to call dismissModalViewControllerAnimated:YES through any button triggered action in your third view. If this works, use NSLog and check the sequence if methods called. This way you can figure out where exactly you should put your dismissModalViewControllerAnimated:YES.

Hope this helps.

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