2011-09-18 25 views
1

我想用放大鏡圖標創建索引的UITableView。 我意識到UITableViewIndexSearch在索引中創建圖標,但我不知道用什麼來替換它。任何幫助或建議將不勝感激。沒有放大鏡的UITableView索引

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
return [[self.fetchedResultsController sections] count];} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
id <NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:section]; 
return [sectionInfo numberOfObjects];} 

- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index { 

return index;} 

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView { 
// Return the array of section index titles 
NSArray *searchArray = [NSArray arrayWithObject:UITableViewIndexSearch]; 
return [searchArray arrayByAddingObjectsFromArray:self.fetchedResultsController.sectionIndexTitles];} 

回答

2

請勿在sectionIndexTitlesForTableView:中加UITableViewIndexSearch。只需從您的fetchedResultsController中返回數組。

+0

- (NSArray的*)sectionIndexTitlesForTableView:(UITableView的*)的tableView {\t \t \t 的NSArray * fetchedObjects = [fetchedResultsController_ sectionIndexTitles]; \t return fetchedObjects; } – OscarTheGrouch

+0

效果很好。謝謝你的幫助! – OscarTheGrouch

4

只需將其替換爲無。只需將UITableViewIndexSearch保持不變即可。