现在的位置: 首页 > 综合 > 正文

iphone获取本机电话号码 iPhone获取通讯录里电话号码

2018年02月13日 ⁄ 综合 ⁄ 共 1044字 ⁄ 字号 评论关闭

代码下载地址:201206131748442348.zip 

 

发现很多人不知道怎么去获取IPHONE的本机号码,所以写了这些代码分享给大家.但是听说iphone是不允许用的,所以用的兄弟能不能在app store上架我就不知道了.呵呵...

步骤如下:

1)导入CoreTelephony这个private framework

2)在xxx.m中加入绿字部分:

 

#import "xxx.h"

extern
NSString *CTSettingCopyMyPhoneNumber();

 
label.text=CTSettingCopyMyPhoneNumber(); 
 

具体可以参看代码 

注意:一定要用真机测试.模拟器是看不到效果滴....

http://www.cocoachina.com/bbs/simple/?t30053.html

http://www.docin.com/p-395068555.html

iPhone获取通讯录里电话号码  

ABAddressBookRef addressBook = ABAddressBookCreate();
peopleArray = (NSMutableArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);
for (id *people in peopleArray)
{
ABMultiValueRef phones = (ABMultiValueRef) ABRecordCopyValue(people, kABPersonPhoneProperty);
int nCount = ABMultiValueGetCount(phones);
for(int i = 0 ;i < nCount;i++)
{
NSString *phonelLable    = (NSString *)ABMultiValueCopyLabelAtIndex(phones, i);
NSString *phoneNO    = (NSString *)ABMultiValueCopyValueAtIndex(phones, i);  // 这个就是电话号码
}
}

http://panccp.blog.163.com/blog/static/2655604420118824346795/

还可以通过下面的方式得到:

NSString *num = [[NSUserDefaults standardUserDefaults] stringForKey:@"SBFormattedPhoneNumber"];

抱歉!评论已关闭.