我已經爲我的tableview實現了一個Section索引。它返回存儲在coredata中的正確字母(A B C D F G H I K M N O P Q R S T U V W
)。但是索引已關閉。sectionIndexTitlesForTableView鍵已關閉?
如果我點擊字母M
需要我信我,等我試圖排序的索引的名稱是name
有什麼,我做修復指標?
我也在執行numberOfSectionsInTableView
,numberOfRowsInSection
和titeForHeaderInSection
。節標題顯示正確。
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
NSArray * sectionTitlesArray = [fetchedResultsController sectionIndexTitles];
NSMutableArray *newTitles = [[NSMutableArray alloc] init];
for (NSString *state in sectionTitlesArray) {
[newTitles addObject:[NSString stringWithFormat:@"%@", state]];
}
return [newTitles autorelease];
}
包括FRC以防萬一它是相關的:
- (NSFetchedResultsController *)fetchedResultsController {
if (fetchedResultsController == nil) {
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"WidgetCoItems" inManagedObjectContext:managedObjectContext];
[fetchRequest setEntity:entity];
NSSortDescriptor *sortDescriptor1 = [[NSSortDescriptor alloc] initWithKey:@"state" ascending:YES];
NSSortDescriptor *sortDescriptor2 = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor1,sortDescriptor2, nil];
[fetchRequest setSortDescriptors:sortDescriptors];
NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:@"state" cacheName:nil];
aFetchedResultsController.delegate = self;
self.fetchedResultsController = aFetchedResultsController;
[aFetchedResultsController release];
[fetchRequest release];
[sortDescriptor1 release];
[sortDescriptor2 release];
[sortDescriptors release];
}
return fetchedResultsController;
}
你能說明什麼代碼調用了你的'fetchedResultsController'方法嗎? I.E.有沒有選定的行/選擇部分的方法? –
我可能是錯的,但據我瞭解,定義的方法隱式加載FRC。沒有我可以看到的「呼叫」。 (IE:viewDidLoad:loadTable:等) – roberthuttinger