Поскольку я обновил XCode (6.0, 6A313) и мою iOS (8.0, 12A365) на iPhone до gm, код ABPeoplePickerNavigationController не работает, как раньше.ABPeoplePickerNavigationController меняется с iOS8?
IOS 7.1.2: Если кто-то хочет импортировать контакты, адресная книга открывается, и вы увидите полный список контактов, после получения его, он открывает подробный вид на контакт и чем вы можете добавить свяжитесь с одним щелчком номера телефона, который вы хотите импортировать.
IOS 8.0: его все похожи, но если нажать на числа в контакте он набрать телефонный номер вместо того, чтобы импортировать его ..
Код:
#pragma mark - AddressBook Delegate Methods
-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person{
return YES;
}
-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{
// Get the first and the last name. Actually, copy their values using the person object and the appropriate
// properties into two string variables equivalently.
// Watch out the ABRecordCopyValue method below. Also, notice that we cast to NSString *.
NSString *firstName = (__bridge NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);
NSString *lastName = (__bridge NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty);
// Compose the full name.
NSString *fullName = @"";
// Before adding the first and the last name in the fullName string make sure that these values are filled in.
if (firstName != nil) {
fullName = [fullName stringByAppendingString:firstName];
}
if (lastName != nil) {
fullName = [fullName stringByAppendingString:@" "];
fullName = [fullName stringByAppendingString:lastName];
}
// Get the multivalue number property.
CFTypeRef multivalue = ABRecordCopyValue(person, property);
// Get the index of the selected number. Remember that the number multi-value property is being returned as an array.
CFIndex index = ABMultiValueGetIndexForIdentifier(multivalue, identifier);
// Copy the number value into a string.
NSString *number = (__bridge NSString *)ABMultiValueCopyValueAtIndex(multivalue, index);
nameTextField.text = fullName;
numberTextField.text = number;
// Dismiss the contacts view controller.
[_addressBookController dismissViewControllerAnimated:YES completion:nil];
return NO;
}
// Implement this delegate method to make the Cancel button of the Address Book working.
-(void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker{
[_addressBookController dismissViewControllerAnimated:YES completion:nil];
}
не мог найти любой ответ в библиотеке разработчика iOS для Apple. есть для кого-то еще решение?
Это не работает для меня на iOS 8.0.1. Существуют ли другие методы делегатов, которые мне нужно реализовать? Мой делегат вообще не попадает, кроме метода отмены. – Alexander
@AlexanderCollins Он отлично подходит для меня с 8.0.1. Вы уверены, что ваш делегат установлен? – rmaddy
Да, мой метод делегирования отменяется правильно. Выбор телефонного номера контакта вызывает этот контакт вместо того, чтобы удалять мой метод didSelect: delegate. – Alexander