より新しいUITableViewのインデックス作成。 私のようないくつかのデモデータ、どのように私はUITableViewのインデックスですか?
tableDataArray = [[NSMutableArray alloc] init];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
[dict setObject:[NSString stringWithFormat:@"Thomas Cook"] forKey:@"Name"];
[dict setObject:[NSString stringWithFormat:@"Dean"] forKey:@"Position"];
[dict setObject:[NSString stringWithFormat:@"[email protected]"] forKey:@"Email"];
[dict setObject:[NSString stringWithFormat:@"67-876-65433"] forKey:@"PhoneNo"];
[tableDataArray addObject:dict];
NSMutableDictionary *dict1 = [[NSMutableDictionary alloc] init];
[dict1 setObject:[NSString stringWithFormat:@"John Appleseed"] forKey:@"Name"];
[dict1 setObject:[NSString stringWithFormat:@"Department of accounting"] forKey:@"Position"];
[dict1 setObject:[NSString stringWithFormat:@"[email protected]"] forKey:@"Email"];
[dict1 setObject:[NSString stringWithFormat:@"45-876-65433"] forKey:@"PhoneNo"];
[tableDataArray addObject:dict1];
NSMutableDictionary *dict2 = [[NSMutableDictionary alloc] init];
[dict2 setObject:[NSString stringWithFormat:@"Amar Smith"] forKey:@"Name"];
[dict2 setObject:[NSString stringWithFormat:@"Department of Human Resource"] forKey:@"Position"];
[dict2 setObject:[NSString stringWithFormat:@"[email protected]"] forKey:@"Email"];
[dict2 setObject:[NSString stringWithFormat:@"54-876-65433"] forKey:@"PhoneNo"];
[tableDataArray addObject:dict2];
NSMutableDictionary *dict3 = [[NSMutableDictionary alloc] init];
[dict3 setObject:[NSString stringWithFormat:@"Mary Cold"] forKey:@"Name"];
[dict3 setObject:[NSString stringWithFormat:@"HOD of Computer Department"] forKey:@"Position"];
[dict3 setObject:[NSString stringWithFormat:@"[email protected]"] forKey:@"Email"];
[dict3 setObject:[NSString stringWithFormat:@"52-876-65433"] forKey:@"PhoneNo"];
[tableDataArray addObject:dict3];
NSMutableDictionary *dict4 = [[NSMutableDictionary alloc] init];
[dict4 setObject:[NSString stringWithFormat:@"John Jobs"] forKey:@"Name"];
[dict4 setObject:[NSString stringWithFormat:@"Department of Physics"] forKey:@"Position"];
[dict4 setObject:[NSString stringWithFormat:@"[email protected]"] forKey:@"Email"];
[dict4 setObject:[NSString stringWithFormat:@"12-876-65433"] forKey:@"PhoneNo"];
[tableDataArray addObject:dict4];
NSMutableDictionary *dict5 = [[NSMutableDictionary alloc] init];
[dict5 setObject:[NSString stringWithFormat:@"Clark Kristan"] forKey:@"Name"];
[dict5 setObject:[NSString stringWithFormat:@"Contact Person"] forKey:@"Position"];
[dict5 setObject:[NSString stringWithFormat:@"[email protected]"] forKey:@"Email"];
[dict5 setObject:[NSString stringWithFormat:@"65-876-65433"] forKey:@"PhoneNo"];
[tableDataArray addObject:dict5];
だから、私は、インデックスのUITableViewを作成したいを持っています。私のUITableViewデリゲートとデータソースメソッドは、それぞれ上記のデータ形式でどのようになりますか?詳細は
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
}
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
}
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index {
}
あなたは(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView { }
で、あなたのインデックスリストに表示し、その配列を返すようにしたいタイトルの配列を作成する必要があるおかげで
ご質問を詳しくお書きください。どのようにデータを表示したいですか? – Maulik
@Maulik、私は名前の最初の文字を使用してテーブルビューのデータにインデックスを付ける必要があります。 – Tirth