删除子视图我的计时器继续运行 - iPhone SDK

发布于 2024-09-12 04:33:10 字数 395 浏览 1 评论 0原文

我有一个 NSTimer 在视图的子视图中运行。我想删除视图,当然还要停止计时器。我似乎能够删除视图(它物理上消失),但计时器继续运行,我仍然可以看到跟踪语句。

这是删除视图的代码......

for (UIView *subview in [self.myViews subviews]) {
    NSLog(@"*****REMOVE current views!!!!!!!!!!!!");
       // Only remove the subviews with tag not equal to 1
    if (subview.tag != 1) {
     NSLog(@"*****!!!");
     [subview removeFromSuperview];
    }

I have a NSTimer running in a subview of a view. I want to remove the view and of course stop the timer. I seem to be able to remove the view (it physically disappears) but the timer keeps running, I can see the trace statements still.

This is the code to remove the view...

for (UIView *subview in [self.myViews subviews]) {
    NSLog(@"*****REMOVE current views!!!!!!!!!!!!");
       // Only remove the subviews with tag not equal to 1
    if (subview.tag != 1) {
     NSLog(@"*****!!!");
     [subview removeFromSuperview];
    }

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

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

发布评论

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

评论(1

一指流沙 2024-09-19 04:33:10

您是否在[subview removeFromSuperview]之后立即尝试了[timer invalidate]

Did you try [timer invalidate] right after [subview removeFromSuperview]?

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