リンクhttp://www.devx.com/wireless/Article/43374を使用して、アルファベット順のセクション ヘッダーを実装しました。
使い勝手が良いです。
このロジックを使用して、最初の文字をインデックスとして取得しました
// To implement indexes and section headers
contactsArray = [[NSMutableArray alloc] init];
for(int i=0; i< tableViewArray.count ; i++)
{
Contact *contact = [tableViewArray objectAtIndex:i];
[contactsArray addObject:contact.name];
}
contactIndex = [[NSMutableArray alloc] init];
for (int i=0; i<[contactsArray count]; i++){
//---get the first char of each contactName---
char alphabet = [[[contactsArray objectAtIndex:i] uppercaseString] characterAtIndex:0];
NSString *firstChar = [NSString stringWithFormat:@"%C", alphabet];
//---add each letter to the index array---
if (![contactIndex containsObject:firstChar])
{
[contactIndex addObject:firstChar];
}
}
ただし、連絡先の場合は1,2,3 を返します...
But need to display # instead of all numaerical values headers