删除子视图我的计时器继续运行 - iPhone SDK
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否在
[subview removeFromSuperview]
之后立即尝试了[timer invalidate]
?Did you try
[timer invalidate]
right after[subview removeFromSuperview]
?