iphone - 获取 iPhone 运营商接收状态? (不是互联网)
<p><p>我需要知道用户理论上是否可以调用电话。</p>
<p>当用户的 iPhone 能够连接到运营商的网络时,有谁知道如何“返回 true”(使用 Cocoa iOS)? (不是互联网)</p>
<p>或者如何以编程方式告诉用户“有多少个接收栏”?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>将您的应用程序与 <strong>CoreTelephony.framework</strong></p> 相关联
<p>您可以检查 <strong>CTCarrier</strong> 对象,看看对于某些需要与 Phone Provider 连接的属性是否有有效结果 (!=nil)。</p>
<p>例如,下面有一段代码用于检查 <strong>CTCarrier</strong> 的 <strong>mobileNetworkCode</strong> 属性。此属性为 != nil 如果且仅当设备连接到电话提供商(您所需的任务,用户能够调用电话,包含在上述状态中)。</p>
<pre><code>CTTelephonyNetworkInfo *netInfo = [ init];
CTCarrier *carrier = ;
//The value for this property is nil if any of the following apply:
//- The device is in Airplane mode.
//- There is no SIM card in the device.
//- The device is outside of cellular service range.
NSString *mnc = ;
if(!mnc) {
//if we're here, than probably we're disconnected from the Phone Provider
}
netInfo.subscriberCellularProviderDidUpdateNotifier = ^ (CTCarrier * carrier) {
//this block is executed each time we've a change to the state of the carrier
//be sure to check the carrier object, in order to see is we're connected to a
//phone provider.
};
</code></pre>
<p>Apple 开发者文档网址中的更多信息:<a href="http://developer.apple.com/library/IOs/#documentation/NetworkingInternet/Reference/CTCarrier/Reference/Reference.html" rel="noreferrer noopener nofollow">http://developer.apple.com/library/IOs/#documentation/NetworkingInternet/Reference/CTCarrier/Reference/Reference.html</a> </p></p>
<p style="font-size: 20px;">关于iphone - 获取 iPhone 运营商接收状态? (不是互联网),我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/8892860/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/8892860/
</a>
</p>
页:
[1]