iPhone - cancelPerformSelectorWithTarget 不起作用
如果我在 UIView 的子类中执行此操作:
[self performSelector:@selector(doSomething) withObject:nil afterDelay:5];
然后像这样取消它(我已经尝试了两个版本):
[[NSRunLoop currentRunLoop] cancelPerformSelectorsWithTarget:self];
//[[NSRunLoop mainRunLoop] cancelPerformSelectorsWithTarget:self];
“doSomething”方法仍然被调用。我做错了什么?
If I do this in a subclass of UIView:
[self performSelector:@selector(doSomething) withObject:nil afterDelay:5];
Then cancel it like this (I've tried both versions):
[[NSRunLoop currentRunLoop] cancelPerformSelectorsWithTarget:self];
//[[NSRunLoop mainRunLoop] cancelPerformSelectorsWithTarget:self];
The "doSomething" method still gets called. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 NSObject 类参考中:
使用:
希望这会有所帮助。
In the NSObject class reference:
Use:
Hope this helps.