I used iphones address b开发者_开发问答ook data in my app ,i sorted that data and arranged in UITableViewController,but now i want to make same look as of address book means sorted in GroupedStyle having initial character as heading of section .and suggestion plz
You have to implement the tableView methods that are
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
for section headers and for this this you also have to implement
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
By doing this your table data can be viewed in grouped style.
Use something like following to sort the contacts:
NSArray* tempArray = [jsonData objectForKey:@"contacts"];
NSSortDescriptor *sortDescriptor;
sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"first_name"
ascending:YES] autorelease];
NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
contactsArray = [[NSArray alloc] initWithArray:[tempArray sortedArrayUsingDescriptors:sortDescriptors]];
From the use NSPredicate to pick the contacts and add them to section that you want.
精彩评论