我想以编程方式拨打电话号码,该电话号码在号码末尾包含#。由于Apple不接受这一点,我认为一种方法是在地址簿中添加联系人并使用它来拨打电话号码。所以我的问题是我如何链接我的应用程序中的联系人?
答案 0 :(得分:0)
您可能需要查看地址簿编程指南: http://developer.apple.com/library/ios/#documentation/ContactData/Conceptual/AddressBookProgrammingGuideforiPhone/Introduction.html
答案 1 :(得分:0)
- (IBAction)addContact:(UIButton *)sender
{
ABAddressBookRef addressBook = NULL;
CFErrorRef error = NULL;
switch (ABAddressBookGetAuthorizationStatus()) {
case kABAuthorizationStatusAuthorized: {
addressBook = ABAddressBookCreateWithOptions(NULL, &error);
[self addAccountWithFirstName:self.firstNameField.text lastName:self.lastNameField.text inAddressBook:addressBook];
if (addressBook != NULL) CFRelease(addressBook);
break;
}
case kABAuthorizationStatusDenied: {
NSLog(@"Access denied to address book");
break;
}
case kABAuthorizationStatusNotDetermined: {
addressBook = ABAddressBookCreateWithOptions(NULL, &error);
ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) {
if (granted) {
NSLog(@"Access was granted");
[self addAccountWithFirstName:self.firstNameField.text lastName:self.lastNameField.text inAddressBook:addressBook];
}
else NSLog(@"Access was not granted");
if (addressBook != NULL) CFRelease(addressBook);
});
break;
}
case kABAuthorizationStatusRestricted: {
NSLog(@"access restricted to address book");
break;
}
}
}##
标题
##