Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 从地址boook获取号码_Iphone_Ios4 - Fatal编程技术网

Iphone 从地址boook获取号码

Iphone 从地址boook获取号码,iphone,ios4,Iphone,Ios4,我想从电话簿中获取choose用户的号码。现在我只能知道他的名字 - (IBAction) showPhoneBook: (id)sender { ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init]; picker.peoplePickerDelegate = self; [self presentModalViewContro

我想从电话簿中获取choose用户的号码。现在我只能知道他的名字

- (IBAction) showPhoneBook: (id)sender {
    ABPeoplePickerNavigationController *picker =
    [[ABPeoplePickerNavigationController alloc] init];
    picker.peoplePickerDelegate = self;
    [self presentModalViewController:picker animated:YES];
    [picker release];
}

- (void)peoplePickerNavigationControllerDidCancel:
    (ABPeoplePickerNavigationController *)peoplePicker {
        [self dismissModalViewControllerAnimated:YES];
}
- (BOOL)peoplePickerNavigationController:
(ABPeoplePickerNavigationController *)peoplePicker
  shouldContinueAfterSelectingPerson:(ABRecordRef)person {

// Select phone number
NSString* name = (NSString *)ABRecordCopyValue(person,
                                               kABPersonFirstNameProperty);

self.number.text = name;

[name release];
[self dismissModalViewControllerAnimated:YES];
return NO;
}

- (BOOL)peoplePickerNavigationController:
  (ABPeoplePickerNavigationController *)peoplePicker
  shouldContinueAfterSelectingPerson:(ABRecordRef)person
                            property:(ABPropertyID)property
                          identifier:(ABMultiValueIdentifier)identifier{
return NO;
}
我怎样才能得到号码而不是名字


致以最诚挚的问候。

要从您可以做的记录中获取电话号码(在您的回调方法中):

更新

ABMultiValueRef phones =(NSString*)ABRecordCopyValue(person, kABPersonPhoneProperty);
NSString* mobile=@"";
NSString* mobileLabel;
for(CFIndex i = 0; i < ABMultiValueGetCount(phones); i++) {
        mobileLabel = (NSString*)ABMultiValueCopyLabelAtIndex(phones, i);
        if([mobileLabel isEqualToString:(NSString *)kABPersonPhoneMobileLabel])
        {
                [mobile release] ;
                mobile = (NSString*)ABMultiValueCopyValueAtIndex(phones, i);
        }
ABMultiValueRef phones=(NSString*)ABRecordCopyValue(person,kABPersonPhoneProperty);
NSString*mobile=@;
NSString*移动标签;
对于(CFIndex i=0;i
使用以下方法:

ABPersonViewController *pvc = [[[ABPersonViewController alloc] init] autorelease];
    pvc.displayedPerson=contact.phonenumbers;

我怎样才能只得到没有并列词的手机和“这正是我想要的:)非常感谢!有没有办法检查手机号码是否有效以发送短信?
ABPersonViewController *pvc = [[[ABPersonViewController alloc] init] autorelease];
    pvc.displayedPerson=contact.phonenumbers;