もともと入っている電話アプリなんかは、タブバーを選択すると連絡先が表示されるようになっていますが、それを実装するために、いろいろ試行錯誤してみましたが、以下のようにすることで、実装出来ました。
この件に関しては、あまり、情報がなかった(モーダルビューにpickerを表示させる例は多々ありましたが・・・)ので、スマートな方法かどうかは不明ですので、もし、もっとスマートな方法をご存知の方がいらっしゃいましたら、是非コメントください。…
– (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @”Cell”; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } //ref of Addressbook ABAddressBookRef book = ABAddressBookCreate(); //Count of Addressbook //CFIndex cnt = ABAddressBookGetPersonCount(book); //NSLog(@”addressbook count is %d “,cnt); //AllRecords of Addressbook CFArrayRef records = ABAddressBookCopyArrayOfAllPeople(book); //record at index=i ABRecordRef person = CFArrayGetValueAtIndex(records,indexPath.row); NSString *firstName = (NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty); NSString *lastName = (NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty); if (firstName == nil) { firstName = @””; } if (lastName == nil) { lastName = @””; } cell.textLabel.text = [NSString stringWithFormat:@”%@ %@”,lastName,firstName]; return cell; }
この投稿へのコメント
コメントはまだありません。