0
IOS에 App이 있고 앱이 있는데 사람들이 그것을 클릭하면 자동으로 연락처 (이름, 번호 및 그림)를 전화 연락처 목록에 추가하는 버튼을 추가하려고합니다.주소록 버튼에 연락처 추가
연락처 이름은 Clinica Lo Curro이고 전화 번호는 6003667800입니다.
누군가 제발 도와주세요. 코드를 알려주세요.
관련,
에우 제 니오 듀란
IOS에 App이 있고 앱이 있는데 사람들이 그것을 클릭하면 자동으로 연락처 (이름, 번호 및 그림)를 전화 연락처 목록에 추가하는 버튼을 추가하려고합니다.주소록 버튼에 연락처 추가
연락처 이름은 Clinica Lo Curro이고 전화 번호는 6003667800입니다.
누군가 제발 도와주세요. 코드를 알려주세요.
관련,
에우 제 니오 듀란
빌드 단계에서 AddressBook.framework 및 AddressBookUI.framework 추가, 바이너리를 라이브러리와 연결. 그리고 아래 표시된 것처럼 AddressBookUI를 헤더 파일로 가져옵니다.
#import <AddressBookUI/AddressBookUI.h>
헤더 파일에 대리인 ABPeoplePickerNavigationControllerDelegate를 포함시킵니다.
및 전화 연락처를 추가하려면 다음 방법을 사용하십시오.
-(IBAction)addContact:(id)sender
{
ABPeoplePickerNavigationController *peoplePicker=[[ABPeoplePickerNavigationController alloc] init];
ABAddressBookRef addressBook = [peoplePicker addressBook];
// create person record
ABRecordRef person = ABPersonCreate();
// set name and other string values
UIImage *personImage = [UIImage imageNamed:@"cinema.png"];
NSData *dataRef = UIImagePNGRepresentation(personImage);
NSString *[email protected]"AKASH";
NSString *[email protected]"MALHOTRA";
NSString *[email protected]"Aua Comp Pvt Ltd.";
NSString *[email protected]"iPhone App Developer";
NSString *[email protected]"Mobile Division";
NSString *[email protected]"http://www.google.com";
NSString *[email protected]"[email protected]";
NSString *[email protected]"9856756445 or 7656876765 or 8976566775";
NSString *[email protected]"I am just a kid";
NSString *[email protected]"HN-23,Sector-2,Chandigarh";
NSString *[email protected]"AL-19,Sector-5,SaltLake";
NSString *[email protected]"Kolkata";
NSString *[email protected]"West Bengal";
NSString *[email protected]"700091";
NSString *[email protected]"India";
CFErrorRef cfError=nil;
ABRecordSetValue(person, kABPersonOrganizationProperty, (__bridge CFStringRef)organization, NULL);
if (firstName) {
ABRecordSetValue(person, kABPersonFirstNameProperty, (__bridge CFTypeRef)(firstName) , nil);
}
if (lastName) {
ABRecordSetValue(person, kABPersonLastNameProperty, (__bridge CFTypeRef)(lastName) , nil);
}
if (jobTitle) {
ABRecordSetValue(person, kABPersonJobTitleProperty,(__bridge CFTypeRef)(jobTitle), nil);
}
if (departMent) {
ABRecordSetValue(person, kABPersonDepartmentProperty,(__bridge CFTypeRef)(departMent), nil);
}
if (personNote) {
ABRecordSetValue(person, kABPersonNoteProperty, (__bridge CFTypeRef)(personNote), nil);
}
if (dataRef) {
ABPersonSetImageData(person, (__bridge CFDataRef)dataRef,&cfError);
}
if (webURL)
{
ABMutableMultiValueRef urlMultiValue = ABMultiValueCreateMutable(kABMultiStringPropertyType);
ABMultiValueAddValueAndLabel(urlMultiValue, (__bridge CFStringRef) webURL, kABPersonHomePageLabel, NULL);
ABRecordSetValue(person, kABPersonURLProperty, urlMultiValue, nil);
CFRelease(urlMultiValue);
}
if (personEmail)
{
ABMutableMultiValueRef emailMultiValue = ABMultiValueCreateMutable(kABMultiStringPropertyType);
ABMultiValueAddValueAndLabel(emailMultiValue, (__bridge CFStringRef) personEmail, kABWorkLabel, NULL);
ABRecordSetValue(person, kABPersonEmailProperty, emailMultiValue, nil);
CFRelease(emailMultiValue);
}
if (phoneNo)
{
ABMutableMultiValueRef phoneNumberMultiValue = ABMultiValueCreateMutable(kABMultiStringPropertyType);
NSArray *venuePhoneNumbers = [phoneNo componentsSeparatedByString:@" or "];
for (NSString *venuePhoneNumberString in venuePhoneNumbers)
ABMultiValueAddValueAndLabel(phoneNumberMultiValue, (__bridge CFStringRef) venuePhoneNumberString, kABPersonPhoneMainLabel, NULL);
ABRecordSetValue(person, kABPersonPhoneProperty, phoneNumberMultiValue, nil);
CFRelease(phoneNumberMultiValue);
}
// add address
ABMutableMultiValueRef multiAddress = ABMultiValueCreateMutable(kABMultiDictionaryPropertyType);
NSMutableDictionary *addressDictionary = [[NSMutableDictionary alloc] init];
if (addressOne)
{
if (addressTwo)
addressDictionary[(NSString *) kABPersonAddressStreetKey] = [NSString stringWithFormat:@"%@\n%@", addressOne, addressTwo];
else
addressDictionary[(NSString *) kABPersonAddressStreetKey] = addressOne;
}
if (cityName)
addressDictionary[(NSString *)kABPersonAddressCityKey] = cityName;
if (stateName)
addressDictionary[(NSString *)kABPersonAddressStateKey] = stateName;
if (pinCode)
addressDictionary[(NSString *)kABPersonAddressZIPKey] = pinCode;
if (country)
addressDictionary[(NSString *)kABPersonAddressCountryKey] = country;
ABMultiValueAddValueAndLabel(multiAddress, (__bridge CFDictionaryRef) addressDictionary, kABWorkLabel, NULL);
ABRecordSetValue(person, kABPersonAddressProperty, multiAddress, NULL);
CFRelease(multiAddress);
//Add person Object to addressbook Object.
ABAddressBookAddRecord(addressBook, person, &cfError);
if (ABAddressBookSave(addressBook, nil)) {
NSLog(@"\nPerson Saved successfuly");
} else {
NSLog(@"\n Error Saving person to AddressBook");
}
}
복사 붙여 넣기 코드 – Warewolf