- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
出于好奇,我正在尝试重写以下代码
// show HUD (with animation)
[SVProgressHUD showWithStatus:@"loading..."];
// wait for HUD to safely finish showing its animation
// (loading HUD will be visible for 1 sec)
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]]
// dismiss HUD
// (dismiss HUD will be visible for 2 sec)
[SVProgressHUD dismissWithSuccess:@"finished!" afterDelay:2];
使用 Grand Central Dispatch 进入代码。
我尝试使用 dispatch_source_t、dispatch_semaphore_t 和 dispatch_after,但效果不是很好:(我需要你的帮助!
请注意,我不想用任何 block 包装 SVProgressHUD 的方法!
最佳答案
你真的不能。或者,您也可以,但最终只是包装 NSRunLoop
内容本身需要大量工作。
在 iOS 和 Mac OS X 的上下文中,主事件循环是一个运行循环,模态面板、HUD 等都是围绕该细节设计的。
您显示的代码是一个嵌套运行循环。您实际上是在外循环内的子循环中运行主运行循环,该外循环也由主运行循环维护! (如果您要在内部循环中触发的操作方法上设置断点,您会在回溯中明白我的意思)。
关于iphone - 如何重写 [NSRunLoop runUntilDate :] to GCD code?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9205260/
sleep 效果很好,但 runUntilDate 在后台线程上不起作用。但为什么? -(IBAction) onDecsriptionThreadB:(id)sender { dispatch_a
我正在编写一个应用程序,它必须与通过 USB 连接的设备进行通信。该应用程序按固定时间轮流从设备发送和接收数据。所有 Rx/Tx 都发生在单独的线程中,否则 UI 将被阻塞。基本结构基本上是这样的。
我试图让这个 runloop 永远运行(如果不是永远至少一天的话)我正在为 runloop 使用以下函数 [self.runLoop runUntilDate:[NSDate dateWithTime
我正在开发一个在应用程序主线程中运行的 UI 测试框架 (KIF-next)。基本流程是: 执行一些测试逻辑。 通过 runUntilDate: 使主循环旋转 0.1 秒。 重复。 这种方法非常有效。
出于好奇,我正在尝试重写以下代码 // show HUD (with animation) [SVProgressHUD showWithStatus:@"loading..."]; // wait
调用 -[NSRunLoop runUntilDate:] 通常是个好主意吗?它似乎没有任何问题,但告诉运行循环从运行循环内部运行让我很紧张。 更多信息: 我现在有一个项目正在从 REST 服务中获取
请考虑以下代码片段: 在第一个中,我调用了一个创建动画的函数。我以一定的时间间隔这样做: start:; [self animationMethod]; [[NSRunLoop currentRunL
在我的应用程序中,有时我使用 performSelector 安排了一堆消息。 在某些情况下,在处理 UI 操作时,我需要等待所有当前计划的选择器触发。 我可以将我的代码放在另一个方法中,并使用 pe
我是一名优秀的程序员,十分优秀!