gpt4 book ai didi

iPhone - cancelPerformSelectorWithTarget 不起作用

转载 作者:行者123 更新时间:2023-12-03 20:09:58 27 4
gpt4 key购买 nike

如果我在 UIView 的子类中执行此操作:

[self performSelector:@selector(doSomething) withObject:nil afterDelay:5];

然后像这样取消它(我已经尝试了两个版本):

 [[NSRunLoop currentRunLoop] cancelPerformSelectorsWithTarget:self];
//[[NSRunLoop mainRunLoop] cancelPerformSelectorsWithTarget:self];

“doSomething”方法仍然会被调用。我做错了什么?

最佳答案

在 NSObject 类引用中:

cancelPreviousPerformRequestsWithTarget:selector:object:

Cancels perform requests previously registered with performSelector:withObject:afterDelay:.

用途:

[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(doSomething) object:nil];

希望这有帮助。

关于iPhone - cancelPerformSelectorWithTarget 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3971195/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com