iPhone - 检测动画的结尾

发布于 2024-08-30 13:17:52 字数 90 浏览 8 评论 0原文

如何检测模态视图动画的结束(当我关闭时)? (我说的是 MFMailComposeViewController 这不是我自己创建的......)

谢谢

How can I detect the end of the animation of a modal view (when I do a dismiss)? (I'm talking about MFMailComposeViewController which is not created by myself...)

Thanks

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

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

发布评论

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

评论(4

-小熊_ 2024-09-06 13:17:52

您的模态视图控制器有一个 -viewDidDisappear: 方法,每当视图从屏幕上删除时就会自动调用该方法。您可以在模态视图控制器中重写此方法来执行您喜欢的操作。

另外,您可能需要考虑在视图控制器中实现 -viewDidAppear: 方法,该视图控制器的视图会因模态视图消失而显示。

Your modal view controller has a -viewDidDisappear: method that is automatically invoked whenever the view is removed from the screen. You can override this method in your modal view controller to do whatever you like.

Also, you may want to consider implementing the -viewDidAppear: method in the view controller whose view gets revealed by your modal view disappearing.

旧人九事 2024-09-06 13:17:52

您可以子类化 MFMailComposeViewController 并重载其 -viewDidDisappear:

@interface MyCtrler : MFMailComposeViewController
@end
@implementation MyCtrler
-(void)viewDidDisappear:(BOOL)animated {
   [super viewDidDisappear:animated];
   // do anything you like
}
@end

You can subclass MFMailComposeViewController and overload its -viewDidDisappear:.

@interface MyCtrler : MFMailComposeViewController
@end
@implementation MyCtrler
-(void)viewDidDisappear:(BOOL)animated {
   [super viewDidDisappear:animated];
   // do anything you like
}
@end
滴情不沾 2024-09-06 13:17:52

我需要在关闭模态视图后做一些事情,并且只有当确定模态视图确实消失(已完全解除分配)时。所以 viewDidDisappear 和模态视图中的朋友对我来说还太早了。

我发现最简单的方法就是用 NSTimer 延迟我的代码。当模态视图调用其委托并且委托调用删除模态视图时,它还会将要在模态视图消失时运行的代码排队。时间大约是 300 毫秒或 400 毫秒。 (有没有办法从某处检索实际时间?)

I needed to do something after dismissing a modal view, and only when it is sure that the modal view is really gone (been completely dealloc-ed). So viewDidDisappear and its friends in the modal view were too early for me.

The easiest I found was to just delay my code with a NSTimer. When modal view calls its delegate and the delegate invokes removing the modal view, it also queues up the code to be run when the modal view is gone. The timing was something like 300ms or 400ms. (Is there a way to retrieve the actual timing from somewhere?)

猫弦 2024-09-06 13:17:52

通常,要在动画完成时收到通知,您可以通过发送 setAnimationDelegate: 到 UIView 类。

当使用 [someVC DismissModalViewControllerAnimated:YES] 关闭 VC 时,您无法设置动画委托,但如果您改为发送 NO 并为 VC 视图执行自己的动画,您可以 设置委托并在动画完成时收到通知。

Normally to be notified when an animation is complete you set a delegate by sending setAnimationDelegate: to the UIView class.

When a VC is dismissed using [someVC dismissModalViewControllerAnimated:YES] you can't set the animation delegate, but if you send NO instead and do your own animation of the VC's view you can set the delegate and be notified when the animation is completed.

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