步驟如下:
1)匯入coretelephony這個private framework
2)在***.m中加入紅字部分:
#import "***.h"
extern nsstring *ctsettingcopymyphonenumber();
@implementation
+(nsstring *)mynumber
@end
其實很多地方都寫了 標識extern nsstring *ctsettingcopymyphonenumber(); 之後就可以直接引用ctsettingcopymyphonenumber()
一開始發現總報錯說無此方法,非常納悶,結果是乙個字母大小寫的問題,汗顏.汗顏
ctsettingcopymyphonenumber(); 這個方法 可以返回 手機號碼
另外機子的唯一標識碼等一些資訊 可以用[uidevice currentdevice] 的uniqueidentifier,name等屬性來獲取
IOS7獲取本機號碼
之前網上流行兩種方式獲取iphone本機號碼 1.讀取使用者設定的號碼 nsstring num nsuserdefaults standarduserdefaults stringforkey sbformattedphonenumber 2.私有api,需要coretelephony.frame...
獲取本機號碼,本機IP
獲取本機號碼 telephonymanager phonemgr telephonymanager this.getsystemservice context.telephony service txtphonenumber.settext phonemgr.getline1number txtph...
紹棠 ios開發 獲取本機的手機號碼
步驟如下 2 在 m中加入紅字部分 import h extern nsstring ctsettingcopymyphonenumb er implementation nsstring mynumber end 其實很多地方都寫了 標識extern nsstring ctsettingcopym...