IOS UIDevice_设备

本文介绍了一个简单的iOS应用示例,展示了如何使用Objective-C语言通过UIViewController来获取设备的名称、型号等基本信息,并监测电池状态及启用距离传感器。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

//

//  ViewController.m

//  UIDevice_设备

//

//  Created by dc008 on 16/1/5.

//  Copyright © 2016 lin. All rights reserved.

//


#import "ViewController.h"


@interface ViewController ()


@end


@implementation ViewController


- (void)viewDidLoad {

    [super viewDidLoad];

    UIDevice *mine = [UIDevice currentDevice];

    NSLog(@"name:%@",mine.name);

    NSLog(@"model:%@",mine.model);

    NSLog(@"localizedModel:%@",mine.localizedModel);

    NSLog(@"systemName:%@",mine.systemName);

    NSLog(@"systemVersion:%@",mine.systemVersion);

    

    mine.batteryMonitoringEnabled = YES;

    NSLog(@"当前电池容量为:%f%%",mine.batteryLevel *100);

    //距离传感器,靠近时屏幕黑屏 

    mine.proximityMonitoringEnabled = YES;

}


- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}


@end


转载于:https://my.oschina.net/u/2499773/blog/597883

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值