zoukankan      html  css  js  c++  java
  • iphone获取sim卡信息

    /*

     iphone获取sim卡信息

     1.加入一个Framework(CoreTelephony.framework).

     2.引入头文件


    #import <CoreTelephony/CTTelephonyNetworkInfo.h>

    #import <CoreTelephony/CTCarrier.h>

     3.初始化

     
     */

    //-----------------------------------

    具体demo
    //-----------------------------------

    #import <UIKit/UIKit.h>

    #import <CoreTelephony/CTTelephonyNetworkInfo.h>

    #import <CoreTelephony/CTCarrier.h>

    @interface RootViewController : UITableViewController

    {

        //声明变量

        CTTelephonyNetworkInfo *networkInfo;

    }

    @end

    @implementation RootViewController


    - (void)viewDidLoad

    {

        [super viewDidLoad];

        self.navigationItem.prompt = @"CTTelephonyNetworkInfo";

        self.navigationItem.title = @"CTCarrier";

      
        //初始化

        networkInfo = [[CTTelephonyNetworkInfo alloc] init];

        //当sim卡更换时弹出此窗口

        networkInfo.subscriberCellularProviderDidUpdateNotifier = ^(CTCarrier *carrier){

            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Sim card changed" delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];

            [alert show];

           
        };

           
    }

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

    {

        //获取sim卡信息

        CTCarrier *carrier = networkInfo.subscriberCellularProvider;

        static NSString *CellIdentifier = @"Cell";

        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

        if (cell == nil) {

            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];

        }

       
        switch (indexPath.row) {

            case 0://供应商名称(中国联通 中国移动)

                cell.textLabel.text = @"carrierName";

                cell.detailTextLabel.text = carrier.carrierName;

                break;

            case 1://所在国家编号

                cell.textLabel.text = @"mobileCountryCode";

                cell.detailTextLabel.text = carrier.mobileCountryCode;

                break;

            case 2://供应商网络编号

                cell.textLabel.text = @"mobileNetworkCode";

                cell.detailTextLabel.text = carrier.mobileNetworkCode;

                break;

            case 3:

                cell.textLabel.text = @"isoCountryCode";

                cell.detailTextLabel.text = carrier.isoCountryCode;

                break;

            case 4://是否允许voip

                cell.textLabel.text = @"allowsVOIP";

                cell.detailTextLabel.text = carrier.allowsVOIP?@"YES":@"NO";

                break;

               
            default:

                break;

        }

       
        return cell;

    }

  • 相关阅读:
    操作系统演进和未来趋势(附下载)
    用树莓派构建一台服务器,永久运行网站
    用 Docker 构建 MySQL 主从环境
    (一)多线程:线程概述
    网站可访问性的五个自动化测试工具
    个人对前端工程化的理解
    MongoDB安装过程中出现service MongoDB failed to start,verify that you have sufficient privileges to start
    前端开发IDE
    atom插件:js,nodejs,es6补全,高度定制化
    atom离线手动安装atom插件
  • 原文地址:https://www.cnblogs.com/Xer-Lee/p/3155061.html
Copyright © 2011-2022 走看看