重绘sfauthorizationpluginview.
-
21-12-2019 - |
题
我正在编写一个自定义身份验证,它具有一些动态内容(当前以标签的形式)。我希望能够响应事件更新标签。
假设以下声明:
-
parent = SFAuthorizationPluginView (subclass)
-
view = NSView (subclass)
-
NSTextField *label = ...
-
-
我按如下方式编辑标签文本(注意:这可以从后台调度队列执行):
[label setStringValue:@"new text"];
我试图使用以下内容强制更新:
-
[label setNeedsDisplay:YES];
-
dispatch_async(dispatch_get_main_queue(), ^{ [label setNeedsDisplay:YES]; });
-
[label display];
-
dispatch_async(dispatch_get_main_queue(), ^{ [label display]; });
-
[[label cell] update];
-
dispatch_async(dispatch_get_main_queue(), ^{ [[label cell] update]; });
-
[[label cell] needsDisplay];
-
dispatch_async(dispatch_get_main_queue(), ^{ [[label cell] needsDisplay]; });
-
[view setNeedsDisplay:YES];
-
dispatch_async(dispatch_get_main_queue(), ^{ [view setNeedsDisplay:YES]; });
-
[self updateView];
-
dispatch_async(dispatch_get_main_queue(), ^{ [self updateView]; });
-
[self displayView]
-
dispatch_async(dispatch_get_main_queue(), ^{ [self displayView]; });
任何想法? (注意:我会在尝试各种选项时编辑这个问题)
解决方案
我认为所有您需要做的就是将标签更新为如下所示:
dispatch_async(dispatch_get_main_queue(), ^{
label.text = "Hello World!";
});
. 不隶属于 StackOverflow