Cocoa 绑定值直到进程结束才更新
我有一个 NSTextField
标签,其值绑定到 controller.status
当我调用一个函数 [controller someFunction]
时,它用 更新状态>[self setStatus:@"Something"];
在该过程完成之前,UI 不会反映更改。状态已成功更改,但我使用文本字段作为用户的状态,因此其值在函数结束之前会多次更改。
为什么 UI 不随着状态值的每次更改而更新?它仅在流程结束时显示当时的状态。
I have an NSTextField
label whose value is bound to controller.status
When I call a function [controller someFunction]
which updates the status with [self setStatus:@"Something"];
the UI does not reflect the change until the process has completed. The status has been successfully changed but I am using the text field as a status for the user so its value will change multiple times before the end of the function.
Why does the UI not update with each change of the status value? It only displays at the end of the process with what the status is then.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为显示仅作为运行循环的一部分进行更新。 这是一个非常相似的问题刚刚提出。
如果您有一个很长的进程,则应该将其移至操作或后台线程,这样就不会阻塞主线程。阻塞主线程会导致您的应用程序看起来没有响应。
Because the display is only updated as part of the run loop. Here's a very similar question asked just moments ago.
If you have a lengthy process, you should move that to an operation or a background thread so that you don't block the main thread. Blocking the main thread causes your application to seem unresponsive.