use below code and do it
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
if([listOfItems count]==0)
{
return 0;
}
if (searching)
{
return 1;
}
else
{
UILocalizedIndexedCollation *currentCollation = [UILocalizedIndexedCollation currentCollation];
return [currentCollation.sectionTitles count];
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (searching)
{
return [copyListofItems count];
}
else
{
if (section==0) {
return 0;
}
if(section<27)
{
NSDictionary *dictionary = [listOfItems objectAtIndex:section-1];
NSArray *array = [dictionary objectForKey:@"Country"];
return [array count];
}
else {
return 0;
}
}
}
now yu need to give titles them
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
if(searching)
return nil;
return [[NSArray arrayWithObject:UITableViewIndexSearch] arrayByAddingObjectsFromArray:
[[UILocalizedIndexedCollation currentCollation] sectionIndexTitles]];
}
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index {
if(searching)
{
return -1;
}
else
{
UILocalizedIndexedCollation *currentCollation = [UILocalizedIndexedCollation currentCollation];
if (index>0)
{
return [currentCollation sectionForSectionIndexTitleAtIndex:index];
}
else
{
return 0;
}
}
}
enjoy!
No comments:
Post a Comment