Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Add Section Index Title search in one section of UITableVIew in iPhone

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 723
    Comment on it

    Add Title search on UItableVIew

    1. - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
    2. {

    3. return [NSArray arrayWithObjects:@"A", @"B", @"C",@"D",@"E",@"F",@"G",@"H",@"I",@"J",@"K",@"L",@"M",@"N",@"O",@"P",@"Q",@"R",@"S",@"T",@"U",@"V",@"W",@"X", @"Y", @"Z", nil];
    4. }

    5.  
    6. - (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
    7. {
    8. for (int i = 0; i< [allnames count]; i++) {
    9. // Here you return the name i.e. Honda,Mazda
    10. // and match the title for first letter of name
    11. // and move to that row corresponding to that indexpath as below
    12. NSString *letterString = [[allnames objectAtIndex:i] substringToIndex:1];
    13. if ([letterString isEqualToString:title]) {
    14. [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];
    15. break;
    16. }
    17. }
    18. }

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: