我一直試圖在文檔加載到視圖中時立即讓我的UI的這一部分立即更新。 awakeFromNib激發粘貼的代碼,然後啓動一個定時器重複每10秒...progressIndicator不會在awakeFromNib發生後大約10秒後更新
我加載了一個默認的存儲位置:〜/電影......它立即顯示..但網絡位置保存在從XML中獲取的文檔似乎在第二次觸發 - (void)updateDiskSpaceDisplay計時器後顯示。
我已經設置斷點,並且知道包含正在投入* fileSystemAttributes值實例變量是網絡位置權當awakeFromNib時...
林困惑,爲什麼它之後第二個奇蹟般地出現而不是立即顯示寫入值。
- (void)updateDiskSpaceDisplay
{
// Obtain information about the file system used on the selected storage path.
NSError *error = NULL;
NSDictionary *fileSystemAttributes = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[[[self settings] containerSettings] storagePath] error:&error];
if(!fileSystemAttributes) return;
// Get the byte capacity of the drive.
long long byteCapacity = [[fileSystemAttributes objectForKey:NSFileSystemSize] unsignedLongLongValue];
// Get the number of free bytes.
long long freeBytes = [[fileSystemAttributes objectForKey:NSFileSystemFreeSize] unsignedLongLongValue];
// Update the level indicator, and the text fields to show the current information.
[totalDiskSpaceField setStringValue:[self formattedStringFromByteCount:byteCapacity]];
[totalDiskSpaceField setNeedsDisplay:YES];
[usedDiskSpaceField setStringValue:[self formattedStringFromByteCount:(byteCapacity - freeBytes)]];
[usedDiskSpaceField setNeedsDisplay:YES];
[diskSpaceIndicator setMaxValue:100];
[diskSpaceIndicator setIntValue:(((float) (byteCapacity - freeBytes)/(float) byteCapacity) * 100.0)];
[diskSpaceIndicator display:YES];
}
想法?
我awakeFromNib:
- (void)awakeFromNib
{
[documentWindow setAcceptsMouseMovedEvents:YES];
[documentWindow setDelegate:self];
[self updateSettingsDisplay];
[self updateDiskSpaceDisplay];
[self setDiskSpaceUpdateTimer:[NSTimer scheduledTimerWithTimeInterval:10.0 target:self selector:@selector(updateDiskSpaceDisplay) userInfo:NULL repeats:YES]];
[self setUpClipInfoTabButtons];
[self performSelector:@selector(setupEngineController) withObject:NULL afterDelay:0.1];
}
什麼是[diskSpaceIndicator display:YES]調用應該做的事情?我沒有在NSProgressIndicator的文檔中看到它。 –
那就是我的UI的名字progressIndicator 我覺得代碼有點錯.. – theprojectabot