태터데스크 관리자

도움말
닫기
적용하기   첫페이지 만들기

태터데스크 메시지

저장하였습니다.
2017.06.16 08:30


 [iOS] 연락처 선택 modal 띄우기


https://developer.apple.com/library/ios/documentation/ContactData/Conceptual/AddressBookProgrammingGuideforiPhone/Chapters/QuickStart.html#//apple_ref/doc/uid/TP40007744-CH2-SW1


ABMultiValueCopyValueAtIndex, ABMultiValueGetCount, ABMultiValueRef, ABPeoplePickerNavigationController, abpeoplepickernavigationcontrollerdelegate, abrecordcopyvalue, addressbookui, CFRelease, didSelectPerson, dismissmodalviewcontrolleranimated, header, import, IOS, kABPersonFirstNameProperty, kABPersonPhoneProperty, NSLog, Objective-C, peoplePickerDelegate, peoplePickerNavigationController, peoplePickerNavigationControllerDidCancel, presentModalViewController, protocol, [iOS] 연락처 선택 modal 띄우기, __bridge_transfer, ㅍ, 연락처 선택 modal, 프로토콜, 프로토콜 선언


1. #import <AddressBookUI/AddressBookUI.h>



2. <ABPeoplePickerNavigationControllerDelegate> 프로토콜 선언



3. modal 띄우기

ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];

picker.peoplePickerDelegate = self;

[self presentModalViewController:picker animated:YES];



4. delegate 함수들 구현

- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker{

    [self dismissModalViewControllerAnimated:YES];

}


- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker didSelectPerson:(ABRecordRef)person{    

NSString *name = (__bridge_transfer NSString*)ABRecordCopyValue(person, kABPersonFirstNameProperty);

NSString *phoneNumber = nil;

ABMultiValueRef phoneNumbers = ABRecordCopyValue(person, kABPersonPhoneProperty);

if (ABMultiValueGetCount(phoneNumbers) > 0){

phone = (__bridge_transfer NSString*) ABMultiValueCopyValueAtIndex(phoneNumbers, 0);

}

CFRelease(phoneNumbers);

[self dismissModalViewControllerAnimated:YES];

NSLog(@“name=%@, phoneNumber=%@“, name, phoneNumber);

}


더보기



저작자 표시 비영리 변경 금지
신고

댓글을 달아 주세요


Posted by 돼지왕왕돼지

티스토리 툴바