Od czasu aktualizacji XCode (6.0, 6A313) i mojego iOS (8.0, 12A365) na iPhone'a do nasion gm, kod ABPeoplePickerNavigationController nie działa tak jak wcześniej.ABPeoplePickerNavigationController zmiany z iOS8?
iOS 7.1.2: Jeśli ktoś chce importować kontakt, książka adresowa otwiera i można zobaczyć pełną listę kontaktów, po wybranie jednej, otwiera widok szczegółów styk i nie można dodać skontaktować się z kliknięciem numeru telefonu, który chcesz zaimportować.
iOS 8.0: jej wszystko podobne, ale jeśli klikniesz na liczbę styk to wybrać numer telefonu zamiast importować go ..
Kod:
#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];
}
nie mógł znajdź odpowiedź w bibliotece programistów Apple na iOS. ma ktoś inny rozwiązanie dla niego?
To nie działa dla mnie w iOS 8.0.1. Czy są inne metody delegatów, które muszę wdrożyć? Mój delegat w ogóle nie jest trafiony, z wyjątkiem metody anulowania. – Alexander
@AlexanderCollins Działa to dobrze dla mnie z 8.0.1. Czy jesteś pewien, że Twój delegat jest ustawiony? – rmaddy
Tak, moja metoda delegowania anulowania jest trafiona poprawnie. Wybieranie numeru telefonu kontaktu po prostu wywołuje ten kontakt zamiast uderzać w wybraną metodę didSelect: delegate. – Alexander