1
我有一個完全標準的NSComboBox。它有一個爲它提供內容的數據源,它工作正常。問題是,當用戶點擊查看列表時,它將一直滾動到列表的底部而不是頂部。我發現NSComboBox列表默認滾動到底部
- (void)scrollItemAtIndexToTop:(NSInteger)index
,並試圖把
[comboBox scrollItemAtIndexToTop:0];
在不同的地方,但它不會做任何事情。這更令人討厭,我無法理解它。
在此先感謝。
編輯:代碼從數據源:
- (NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox
{
return [[engineTypesArrayController arrangedObjects] count];
}
- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)index
{
return [[[engineTypesArrayController arrangedObjects] objectAtIndex:index] valueForKey:@"title"];
}
- (NSString *)comboBoxCell:(NSComboBoxCell *)aComboBoxCell completedString:(NSString *)uncompletedString
{
NSArray *matchingObjects = [[engineTypesArrayController arrangedObjects] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"(logTenCustomizationProperty_title BEGINSWITH[c] %@)", uncompletedString]];
if (matchingObjects && ([matchingObjects count] > 0))
{
return [[matchingObjects objectAtIndex:0] valueForKey:@"title"];
}
else
{
return nil;
}
}
組合框:indexOfItemWithStringValue未實現。
我沒有得到一個組合框和一個數據源此行爲。發佈您用於數據源的代碼。 – rdelmar 2012-07-15 04:28:14