2

ABPeoplePickerNavigationViewController をカスタマイズして、最初の行に FullName を表示し、次の行に電子メール、電話番号を表示するにはどうすればよいでしょうか。これは連絡先の選択では発生しませんが、ABPickerController ビューが読み込まれるとデフォルトになります。

私が欲しいのは、ABPeoplePicker の通常の機能です。ただし、連絡先の表示には、上記で説明した追加情報が必要です。

ABPeoplePickerNavigationController を拡張する必要があると思いますか? これに関するガイダンスをいただければ幸いです。

4

2 に答える 2

1

ABPeoplePicker.... と addressBook を連携させたい場合、解決策はありません。同じことを試みましたが、最終的に新しいカスタム インデックス付きテーブル ビューを作成しました。とても簡単でした。インデックス付きの tableView を作成したい場合は、 indexed-ui-tableviewをご覧ください。

その後、次の方法を変更して、情報を複数行に表示できます。

- (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] autorelease];
}
cell.textLabel.text = [[[content objectAtIndex:indexPath.section] objectForKey:@"rowValues"] 
                       objectAtIndex:indexPath.row];
cell.detailTextLabel.text=[NSString stringWithFormat:@"%@ %@ %@", @"someone@gmail.com", @"|",@"123456777777777777777"] ;;

return cell;

}

データ ジェネレーターは、モデルに合わせて変更できます。メールなどはモデルから取得できます。上記のスニペットでは、ハードコードされています。その後、検索機能を簡単に接続できます。

于 2012-12-19T13:26:28.917 に答える
1
- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker {
// assigning control back to the main controller
[self dismissModalViewControllerAnimated:YES];
}

- (BOOL)peoplePickerNavigationController: (ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person {
NSString *firstname=(NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);
Usernametf.text=firstname;
 ABMultiValueRef phoneNumbers = ABRecordCopyValue(person, kABPersonPhoneProperty);
ABMultiValueRef addressProperty = ABRecordCopyValue(person, kABPersonAddressProperty);
NSArray *address = (NSArray *)ABMultiValueCopyArrayOfAllValues(addressProperty);

      NSString* phone;
     phone = (NSString*)ABMultiValueCopyValueAtIndex(phoneNumbers, 0);
     phoneNotf.text=phone;
     //NSLog(@"%@",phone);

if([address count] > 0)
{
    for (NSDictionary *addressDict in address)
    {
      NSString*  countrytf = [addressDict objectForKey:@"Country"];
      NSString*  streetaddresstf= [addressDict objectForKey:@"Street"];
      NSString*  citynametf = [addressDict objectForKey:@"City"];
      NSString*  statenametf = [addressDict objectForKey:@"State"];
       NSString* zipcodetf = [addressDict objectForKey:@"ZIP"];
    }
    CFRelease(addressProperty);
}

  //  NSMutableDictionary *dict=[[NSMutableDictionary alloc] initWithObjectsAndKeys:firstname,@"FirstName", nil];
//[selectedemailArray addObject:dict];
// NSLog(@"\n array is %@",selectedemailArray);


//[objDatabase insertArray:selectedemailArray forTable:@"EmailList"];
//[objDatabase insertDictionary:dict forTable:@"EmailList"];
 //    [dict release];
  //    dict =nil;

// remove the controller
[self dismissModalViewControllerAnimated:YES];
return NO;

 }

 - (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{
return NO;
 }

これは、連絡先から何でも取得できるコード全体です。

それが機能しているかどうかを教えてください...

ハッピーコーディング!!!!

于 2012-12-14T06:24:23.137 に答える