佔坑app
ABPeoplePickerNavigationController *peoleVC = [[ABPeoplePickerNavigationController alloc] init];ide
peoleVC.peoplePickerDelegate = self;orm
peoleVC.delegate = self;索引
[self presentViewController:peoleVC animated:YES completion:nil];ci
// 設置標題導航欄的顏色string
if ([[[UIDevice currentDevice] systemVersion] floatValue]>=9.0){it
[[UINavigationBar appearance] setTintColor:[UIColor blackColor]];io
}else{table
[[UINavigationBar appearanceWhenContainedIn:[ABPeoplePickerNavigationController class], nil] setTintColor:[UIColor blackColor]];class
}
===========================================================================================
#pragma mark - ABPeoplePickerNavigationControllerDelegate
-(BOOL) peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{
NSString *name = (__bridge NSString *)ABRecordCopyCompositeName(person);
NSString *phone;
//判斷點擊的區域
if (property == kABPersonPhoneProperty)
{
//取出當前點擊的區域中全部的內容
ABMutableMultiValueRef phoneMulti = ABRecordCopyValue(person,kABPersonPhoneProperty);
//根據點擊的那一行對應的identifier取出所在的索引
long index = ABMultiValueGetIndexForIdentifier(phoneMulti, identifier);
//根據索引把相應的值取出
phone = (__bridge NSString *)ABMultiValueCopyValueAtIndex(phoneMulti, index);
ZW_DEBUG_Log(@"******************>>>>%@",phone);
}
// LRAddPhoneUrgencyCell *phoneCell = [_tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0]];
// phoneCell.textFld.text = [NSString stringWithFormat:@"%@",phone];
if (phone) {
phone = [phone stringByReplacingOccurrencesOfString:@"-" withString:@""];
}
[self setUserNameFldText:[NSString stringWithFormat:@"%@",phone] withPhoneZone:phoneZone];
LRAddPhoneUrgencyCell *nameCell = [_tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:0]];
nameCell.textFld.text = [NSString stringWithFormat:@"%@",name];
[peoplePicker dismissViewControllerAnimated:YES completion:nil];
return NO;
}
- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker{
[peoplePicker dismissViewControllerAnimated:YES completion:nil];
}
- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
didSelectPerson:(ABRecordRef)person
property:(ABPropertyID)property
identifier:(ABMultiValueIdentifier)identifier{
NSString *name = (__bridge NSString *)ABRecordCopyCompositeName(person);
NSString *phone;
//判斷點擊的區域
if (property == kABPersonPhoneProperty)
{
//取出當前點擊的區域中全部的內容
ABMutableMultiValueRef phoneMulti = ABRecordCopyValue(person,kABPersonPhoneProperty);
//根據點擊的那一行對應的identifier取出所在的索引
long index = ABMultiValueGetIndexForIdentifier(phoneMulti, identifier);
//根據索引把相應的值取出
phone = (__bridge NSString *)ABMultiValueCopyValueAtIndex(phoneMulti, index);
ZW_DEBUG_Log(@"******************>>>>%@",phone);
}
// LRAddPhoneUrgencyCell *phoneCell = [_tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0]];
// phoneCell.textFld.text = [NSString stringWithFormat:@"%@",phone];
if (phone) {
phone = [phone stringByReplacingOccurrencesOfString:@"-" withString:@""];
}
[self setUserNameFldText:[NSString stringWithFormat:@"%@",phone] withPhoneZone:phoneZone];
LRAddPhoneUrgencyCell *nameCell = [_tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:0]];
nameCell.textFld.text = [NSString stringWithFormat:@"%@",name];
}