我已经在我的应用程序中实现了一个地址簿框架,我正在创建一个新联系人并在其中设置一些信息,然后稍后再显示。但是当我实际显示视图时,当我点击相应的按钮时,我无法打开电话应用程序或电子邮件应用程序。以下是我创建和保存信息的方式:
ABRecordRef record = ABPersonCreate();
ABMutableMultiValueRef phoneMulti = ABMultiValueCreateMutable(kABMultiStringPropertyType);
ABMutableMultiValueRef address = ABMultiValueCreateMutable(kABDictionaryPropertyType);
ABMutableMultiValueRef emailMultiValue = ABMultiValueCreateMutable(kABPersonEmailProperty);
ABMultiValueAddValueAndLabel(emailMultiValue, @"someone_somewhere@abc.com", (CFStringRef)@"email", NULL);
CFStringRef keys[5];
CFStringRef values[5];
keys[0] = kABPersonAddressStreetKey;
keys[1] = kABPersonAddressCityKey;
keys[2] = kABPersonAddressStateKey;
keys[3] = kABPersonAddressZIPKey;
keys[4] = kABPersonAddressCountryKey;
values[0] = CFSTR("ABC way");
values[1] = CFSTR("Toronto");
values[2] = CFSTR("ON");
values[3] = CFSTR("L1A2B3");
values[4] = CFSTR("Canada"); //This is static
CFDictionaryRef aDict = CFDictionaryCreate(
kCFAllocatorDefault,
(void *)keys,
(void *)values,
5,
&kCFCopyStringDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks
);
ABMultiValueAddValueAndLabel(address, aDict, kABHomeLabel, NULL);
CFRelease(aDict);
// Set up Phone Number
ABMultiValueAddValueAndLabel(phoneMulti, @"12345678910", kABWorkLabel, NULL);
ABRecordSetValue(record, kABPersonFirstNameProperty, firstName, NULL);
ABRecordSetValue(record, kABPersonLastNameProperty, lastName, NULL);
ABRecordSetValue(record, kABPersonNoteProperty, (CFStringRef)@" ", NULL);
ABRecordSetValue(record, kABPersonAddressProperty, address, NULL);
ABRecordSetValue(record, kABPersonEmailProperty, emailMultiValue, NULL);
ABRecordSetValue(record, kABPersonPhoneProperty, phoneMulti, nil);
我正在使用 anUnknownPersonViewController
在另一个视图中访问记录。
ABUnknownPersonViewController *contactDetailsView = [[ABUnknownPersonViewController alloc]init];
contactDetailsView.allowsActions = YES;
contactDetailsView.displayedPerson = record;
[[self navigationController] pushViewController:contactDetailsView animated:YES];
为什么我不能做任何事情(打电话、发邮件、写便条)当我在我的contactDetailsView
? 我该如何解决?我正在使用 iOS 5。