テーブルビューで、連絡先の名前、会社名、連絡先の写真を表示する必要があります。
連絡先の追加/編集ページから連絡先を追加/編集できます。
追加/編集ページに値を入力すると、それらを辞書に保存します。
配列ContactsArrayでContactNamesを取得し、この配列を使用してセクションとヘッダーを設定しようとしました。
このプロセスでは、保存したものが他のフィールドに表示されません。didSelectRowメソッドでもこの問題が発生した場合でも、詳細なテキストラベルを確認してください。
いずれかのセクションの1行目を選択すると、1番目のセクションの1sr行の詳細ページに移動します。
いずれかのセクションの2行目を選択すると、1番目のセクションの2行目の詳細ページに移動します
セクションの問題かもしれません
//ViewDidLoadメソッドの内部
sections = [[NSMutableDictionary alloc] init]; ///Global Object
BOOL found;
for (NSString *temp in contactsArray)
{
NSString *c = [temp substringToIndex:1];
found = NO;
for (NSString *str in [sections allKeys])
{
if ([str isEqualToString:c])
{
found = YES;
}
}
if (!found)
{
[sections setValue:[[NSMutableArray alloc] init] forKey:c];
}
}
for (NSString *temp in contactsArray)
{
[[sections objectForKey:[temp substringToIndex:1]] addObject:temp];
}
[contactsTable reloadData];
}
テーブルビューメソッド
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return [[sections allKeys]count];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [[sections valueForKey:[[[sections allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)] objectAtIndex:section]] count];
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString* CellIdentifier = @"Cell";
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == Nil)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
NSString *titleText = [[sections valueForKey:[[[sections allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)] objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row];
cell.textLabel.text = titleText;
Contact *contact = [storedContactsArray objectAtIndex:indexPath.row];
Contact *contactPicture = [storedPicsArray objectAtIndex:indexPath.row];
_____________________________________
cell.detailTextLabel.text = contact.companyName;
UIImage *contactImage = [[UIImage alloc]initWithContentsOfFile:contactPicture.contactImage];
cell.imageView.image = contactImage;
_______________________________
return cell;
}
私がBbを宗派にしたときでさえ、それはAAAAAページの詳細にナビゲートします。
このリンク http://www.devx.com/wireless/Article/43374/0/page/2でも試してみましたが、同じ問題を繰り返しても
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
EditContact *editContact = [[EditContact alloc] init];
if([self.storedContactsArray count] != 0)
{
Contact *contactsDict = [storedContactsArray objectAtIndex:indexPath.row];
editContact.contactInfo = contactsDict;
Contact *picsDict = [storedPicsArray objectAtIndex:indexPath.row];
editContact.storedPicsDict = picsDict;
}
[self.navigationController pushViewController:editContact animated:YES];
[editContact release];
[storedContactsArray release];
}