現在、グループ化されたオプションにUITableViewControllerがあります。プロフィールの連絡先画像とその名前が隣接しているアドレス帳UIに似たものを作成しようとしています。下の画像のように、会社名の上にプロフィール写真を追加し、写真のほかに人の名前を追加する方法はありますか?任意の例またはAppleBookReferenceが役立ちます。

現在、グループ化されたオプションにUITableViewControllerがあります。プロフィールの連絡先画像とその名前が隣接しているアドレス帳UIに似たものを作成しようとしています。下の画像のように、会社名の上にプロフィール写真を追加し、写真のほかに人の名前を追加する方法はありますか?任意の例またはAppleBookReferenceが役立ちます。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// Create
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
//cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
}
// Configure
switch (indexPath.row) {
case 0:
cell.textLabel.text = @" Evolutions";
cell.backgroundColor=[UIColor clearColor];
cell.textLabel.textColor=[UIColor whiteColor];
CGRect myImageRect =CGRectMake(20,10,75,80);
UIImageView *imageView = [[UIImageView alloc] initWithFrame:myImageRect];
[imageView setImage:[UIImage imageNamed:@"page-1.jpg"]];
[cell addSubview :imageView];
[imageView release];
UIButton *btnView= [UIButton buttonWithType:UIButtonTypeRoundedRect];
[btnView addTarget:self action:@selector(View:)forControlEvents:UIControlEventTouchDown];
[btnView setTitle:@"View" forState:UIControlStateNormal];
[btnView setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
btnView.frame=CGRectMake(235,36, 72,30 );
[ cell addSubview: btnView];
break;

この画像のようなアドレス帳を作成したいので、このコードを使用します。
連絡先の名前と画像を取得するコードは次のとおりです。
+ (NSMutableArray *) getAllContacts {
// Fetch the address book
ABAddressBookRef addressBook = ABAddressBookCreate();
NSArray *people = (NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);
NSMutableArray *contacts = [NSMutableArray array];
for (CFIndex i = 0; i < [people count]; i++) {
ABRecordRef record = [[people objectAtIndex:i] retain];
NSString *fullname =(NSString *)ABRecordCopyCompositeName(record);
NSMutableDictionary *dict = [NSMutableDictionary dictionary] ;
if (![contacts containsObject:fullname]) {
[dict setValue:fullname forKey:@"name"];
changes = YES;
}
if (ABPersonHasImageData(record)) {
UIImage *image = [UIImage imageWithData:(NSData *)ABPersonCopyImageData(record)];
[dict setObject:image forKey:@"image"];
changes = YES;
}
CFRelease(record);
[fullname release];
}
CFRelease(addressBook);
[people release];
return contacts;
}
セルに関しては、連絡先の画像と連絡先の名前として cell.imageView.image と cell.textLabel.text を設定するだけです。さらにカスタマイズが必要な場合は、既に実装されているスタイルを避けて、独自のスタイルを作成してください。