gpt4 book ai didi

iphone - 使用 performSelector :withObject:afterDelay: with non-object parameters

转载 作者:太空狗 更新时间:2023-10-30 03:24:50 26 4
gpt4 key购买 nike

我想稍微延迟地在 TableView 上调用 setEditing:animated:。通常,我会使用 performSelector:withObject:afterDelay: 但是

  1. pSwOaD 只接受一个参数
  2. setEditing:animated: 的第二个参数是原始 BOOL - 不是对象

过去我会在自己的类中创建一个虚拟方法,比如 setTableAnimated 然后调用 [self performSelector:@selector(setTableAnimated) withObject:nil afterDelay:0.1f 但我觉得这很笨拙。

有更好的方法吗?

最佳答案

为什么不使用 dispatch_queue ?

  double delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[tableView setEditing …];
});

关于iphone - 使用 performSelector :withObject:afterDelay: with non-object parameters,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5210733/

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