【问题标题】:Force update of NSTextField强制更新 NSTextField
【发布时间】:2010-10-13 15:27:48
【问题描述】:

我有一个 NSTextField,当我的应用搜索数组时会更新:

for (NSString *file in fileinDir)
{
        processedFiles = processedFiles + 1;

        NSArray*filesinDevice = [fm contentsOfDirectoryAtPath:[[dict objectForKey:NSWorkspaceVolumeURLKey] path] error:nil];

        [progressLabel setStringValue:[NSString stringWithFormat:@"Copying %@ (%i out of %i)",file,processedFiles,[filesinDevice count]]];

        NSLog(@"%@",[NSString stringWithFormat:@"Copying %@ (%i out of %i)",file,processedFiles,[filesinDevice count]]);

}

NSLog 语句可以按时正常更新,但是 NSTextField 需要一些时间来更新,并且有时会遗漏一些文件编号(比如说 Copying Test.txt (3 out of 10) 然后跳转到 (9 out of 10) )

如何强制更新文本字段?不幸的是没有重绘方法...:/

【问题讨论】:

    标签: objective-c nsstring nstextfield


    【解决方案1】:

    你可以试试[progressLabel display]

    【讨论】:

    • ok 解决了崩溃错误 - 但由于我的文本字段位于 NSMenuItem 上,一旦文本字段的值发生更改,它将不断取消选择它。
    猜你喜欢
    • 1970-01-01
    • 2014-05-20
    • 1970-01-01
    • 2012-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-26
    • 2018-12-26
    相关资源
    最近更新 更多