- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 sierra
操作系统上实现了 NSProgressIndicator
,它在其上的应用程序中运行良好。但是,当我将应用程序移动到 high-sierra< 时进行测试
或 mojave
,进度条
根本不显示,但在 sierra
当单击应用程序中的按钮时,在按钮功能内,我启动了进度条,如下所示,
[_progressbar startAnimation:sender];
[_progressbar setHidden:false];
当我返回时,我将setHidden
更改为true
。那么,我哪里可能出错了?
更新:我尝试使用以下代码,
//Create the block that we wish to run on a different thread.
void (^progressBlock)(void);
progressBlock = ^{
[_progressbar setDoubleValue:0.0];
[_progressbar startAnimation:sender];
[_progressbar setHidden:false];
// running = YES; // this is a instance variable
//NOTE: It is important to let all UI updates occur on the main thread,
//so we put the following UI updates on the main queue.
dispatch_async(dispatch_get_main_queue(), ^{
[_progressbar setNeedsDisplay:YES];
});
// Do some more hard work here...
}; //end of progressBlock
dispatch_queue_t queue = dispatch_get_global_queue(0,0);
dispatch_async(queue,progressBlock);
最佳答案
我在旧的 macOS 应用程序上注意到了这个问题,如果我没记错的话,这是在 High Sierra Beta 中首次测试后发生的,正如您刚刚发现的那样。
大多数用户界面 View 需要主线程来绘制或接收用户输入。但似乎在早期的 macOS 版本中,Apple 做了一些魔法,让 NSProgressIndicator 显示并动画化,即使主线程正忙于做其他工作。然后在最近的 macOS 版本(10.13?)中,这个魔力似乎已被删除。
在主线程上进行长时间运行的工作从来都不是一个好主意,因为它会使用户界面中的其他 View (从未具有 NSProgressIndicator 魔力)对用户没有响应。我认为苹果公司已经意识到了这一点,因为我们现在都是多线程的 Dispatch (也称为中央调度),是时候移除魔法了,这对他们来说可能很难维持。我一直发现它有点问题而且不可靠。
所以答案是,您需要从主线程获取进度指示器正在跟踪的任何工作。您可能会使用 dispatch_async()和 friend 们,尽管 NSOperation 和 NSOperationQueue 仍然可以工作并且也将完成这项工作。
关于objective-c - Mojave 上的 NSProgressIndicator 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56015982/
我正在使用 cocoa 开发一个应用程序,我需要计算 NSProgressIndicator 的剩余时间。这可能吗??? 提前致谢...... 最佳答案 这是一道“一根绳子有多长”的问题。如果不了解您
我有一个 NSProgressIndicator (旋转),当它没有动画时显示良好,但一旦开始动画它就会消失。但是,当我将样式切换为进度条时,它显示得很好,包括动画等等。此外,当它停止动画时它会重新出
我喜欢子类化 NSProgressIndicator。我使用了这段代码,并在 Interface Builder 中设置了子类: - (void)drawRect:(NSRect)dirtyRect
我在我的 cocoa 应用程序中使用“旋转器”NSProgressIndicator: 我想以不同的颜色显示它,以便它在深色背景上显示良好: 我该如何去做呢?我的最后一招是编写自己的自定义 NSVie
我想显示一个不确定的 NSProgressIndicator在我的应用程序中,但我在网上找不到任何明确告诉我如何操作的内容。有人可以向我指出某种教程或提供一些示例代码吗? 最佳答案 如果你想要一个进度
我有一个 NSProgressIndicator(进度条),当在这样的委托(delegate)方法中时,它似乎可以完美地工作: func restClient(client: DBRestClient
无法让 NSProgressIndicator 具有清晰的背景,无论如何它都显示为灰色背景: let progressbar = NSProgressIndicator.init(frame: NSR
我想使用 NSProgressIndicator 来显示一些进度。但我找不到增加该控制栏的方法。我也没有在网上找到示例。 let progressbar = NSProgressIndicator()
当我将进度指示器的背景设置为绿色时,它会按预期工作。 代码: loadingIndicator.wantsLayer = true loadingIndicator.layer?.background
NSProgressIndicator 允许在 isInminated == YES 时使用 stopAnimation:,但是如何停止确定进度条的动画呢? 对于上下文,我尝试执行此操作的进度条是 N
我会很简短: 我正在使用drawrect和NSBezierPath绘制线条。 为了绘制这些线,我使用了 for 循环。 现在,由于循环需要很多秒,我正在尝试使用 NSProgresIndicator
我正在制作一个对多个文件进行大量计算的应用程序,因此为了跟踪正在发生的所有事情,我添加了一个 NSProgressIndicator(值 0-100)。 我的应用程序中还有一个控制台,因此 logCo
我有 NSStatusItem 和显示图像的自定义 NSView。无论菜单是否打开,它都会显示不同的图像,如下所示: isMenuVisible = NO; - (void)awakeFromNib
我的主窗口 Controller 有一个工具栏项目,可以触发模式表的呈现。该工作表应该显示一个漫长的异步过程的进度(例如,将本地数据与服务器同步)。 但是,我无法让(不确定的)进度指示器动画化。 这是
我正在显示一个进度条来显示上传数据的进度。当我完成上传过程时,我有一些最终确定步骤,此时我计划将进度条的状态更改为中间状态(就像 mac 安装程序在安装过程的最后一刻显示的那样)。所以我所做的是将状态
我试图弄清楚如何使用辅助线程更新 UI 中不确定的 NSProgressIndicator,而主线程则执行一些繁重的工作,就像数十个应用程序所做的那样。此代码段基于 Apple 的“Trivial T
我有一个 NSTableView,其中包含两列,每行一个 NSTextField 和一个 NSProgressIndicator 对象。当我向上或向下滚动 NSProgressIndicator 对象
我的主运行循环上运行着一个 for 循环。我正在尝试使用进度指示器来显示正在发生的事情。问题是 UI 永远没有机会更新。 我看过NSProgressIndicator progress with Fo
我想更改在 NSProgressIndicator 栏中绘制的默认渐变的颜色。最简单的方法是什么? 最佳答案 最简单的方法是更改色调......请参阅屏幕截图以更好地理解...... 然后您将看到
默认情况下, cocoa 进度条有点粗,我想要一些更细的东西,就像 Finder 复制对话框中看到的进度条一样。但是,Interface Builder 将 NSProgressIndicator 控
我是一名优秀的程序员,十分优秀!