iphone - How to navigate to a UITableView position by the cell it's title using indexing -


i'm using uitableview filled around 200 cells containing title, subtitle , thumbnail image. want have selection method within contact app apple can select character alphabet.

i'm @ point i've drawn selection interface (a,b,c etc), , via it's delegate i'm retrieving respective index , title (i.e: = 1, b = 2, c = 3 etc.).

now want navigate first cell, first character of cell it's title starting selected index character. contacts app.

can give me direction how implement such functionality.

- (nsinteger)tableview:(uitableview *)tableview sectionforsectionindextitle:(nsstring *)title atindex:(nsinteger)index 

i filled sectionindex means of

- (nsarray *)sectionindextitlesfortableview:(uitableview *)tableview {      if(searching)         return nil;      nsmutablearray *temparray = [[nsmutablearray alloc] init];     [temparray addobject:@"a"];     [temparray addobject:@"b"];     [temparray addobject:@"c"];     [temparray addobject:@"d"];     [temparray addobject:@"e"];     [temparray addobject:@"f"];     [temparray addobject:@"g"];     [temparray addobject:@"h"];     [temparray addobject:@"i"];     [temparray addobject:@"j"];     [temparray addobject:@"k"];     [temparray addobject:@"l"];     [temparray addobject:@"m"];     [temparray addobject:@"n"];     [temparray addobject:@"o"];     [temparray addobject:@"p"];     [temparray addobject:@"q"];     [temparray addobject:@"r"];     [temparray addobject:@"s"];     [temparray addobject:@"t"];     [temparray addobject:@"u"];     [temparray addobject:@"v"];     [temparray addobject:@"w"];     [temparray addobject:@"x"];     [temparray addobject:@"y"];     [temparray addobject:@"z"];      return temparray; } 

try this:-

#pragma mark - #pragma mark uitableview data source , delegate methods  - (nsinteger)numberofsectionsintableview:(uitableview *)tableview {     return [contactarr count]; }  - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section {     /*      if requesting table view search display controller's table view, return count of filtered list, otherwise return count of main list.      */         return [[[contactarr objectatindex:section]objectforkey:@"name"] count];  }  - (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath {     return 44.0f; }  #pragma mark -  - (nsstring *)tableview:(uitableview *)tableview titleforheaderinsection:(nsinteger)section {         return [[contactarr objectatindex:section]objectforkey:@"char"];  }  - (nsarray *)sectionindextitlesfortableview:(uitableview *)tableview  {      nsmutablearray *temparray = [[nsmutablearray alloc] init];     [temparray addobject:@"a"];     [temparray addobject:@"b"];     [temparray addobject:@"c"];     [temparray addobject:@"d"];     [temparray addobject:@"e"];     [temparray addobject:@"f"];     [temparray addobject:@"g"];     [temparray addobject:@"h"];     [temparray addobject:@"i"];     [temparray addobject:@"j"];     [temparray addobject:@"k"];     [temparray addobject:@"l"];     [temparray addobject:@"m"];     [temparray addobject:@"n"];     [temparray addobject:@"o"];     [temparray addobject:@"p"];     [temparray addobject:@"q"];     [temparray addobject:@"r"];     [temparray addobject:@"s"];     [temparray addobject:@"t"];     [temparray addobject:@"u"];     [temparray addobject:@"v"];     [temparray addobject:@"w"];     [temparray addobject:@"x"];     [temparray addobject:@"y"];     [temparray addobject:@"z"];      return temparray; //    return [[nsarray arraywithobject:uitableviewindexsearch] arraybyaddingobjectsfromarray: //            temparray];  }  - (nsinteger)tableview:(uitableview *)tableview sectionforsectionindextitle:(nsstring *)title atindex:(nsinteger)index { //  if (title == uitableviewindexsearch) { //            [tableview scrollrecttovisible:self.searchdisplaycontroller.searchbar.frame animated:no]; //            return -1; //        } else {             return [[uilocalizedindexedcollation currentcollation] sectionforsectionindextitleatindex:index];  } 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -