本文介绍了以编程方式从iPhone检索运营商名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法以编程方式知道iPhone上的手机运营商?
Is there a way to know the cell carrier on an iPhone programatically ?
**更新**
我正在寻找iPhone所连接的运营商名称。
I am looking for the carrier name which the iPhone is connected to.
推荐答案
在iOS 4中,CoreTelephony框架是可用的,这是获取运营商名称的代码段:
In iOS 4, the CoreTelephony framework is useable, here's a snippet to get the carrier name:
CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = [netinfo subscriberCellularProvider];
NSLog(@"Carrier Name: %@", [carrier carrierName]);
[netinfo release];
链接CoreTelephony并包含在您的标题中:
Link against CoreTelephony and include in your headers:
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#import <CoreTelephony/CTCarrier.h>
这篇关于以编程方式从iPhone检索运营商名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!