3
如果我的UIView的子类,这样做:iPhone cancelPerformSelectorWithTarget不工作
[self performSelector:@selector(doSomething) withObject:nil afterDelay:5];
然后取消像这样(我试过两个版本):
[[NSRunLoop currentRunLoop] cancelPerformSelectorsWithTarget:self];
//[[NSRunLoop mainRunLoop] cancelPerformSelectorsWithTarget:self];
的 “DoSomething的”方法仍然被调用。我究竟做错了什么?
+1我想我最近也注意到了这一点;我无法让它工作,所以我最终使用了一个不重复的'NSTimer'。 :P – 2010-10-19 17:56:34
但这不一定与NSTimer有关。它只是取消一个请求... – sol 2010-10-19 18:03:06
你确定两个方法在同一个线程上运行吗?因为如果他们不那么他们针对不同的运行循环。 – DarkDust 2010-10-19 18:06:34