开发者

Removing a subview my timer keeps running - iPhone SDK

开发者 https://www.devze.com 2023-01-09 18:21 出处:网络
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 ke

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];
    }


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

0

精彩评论

暂无评论...
验证码 换一张
取 消