<a href="http://my.oschina.net/u/2340880/blog/547458#">?</a>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<code>//擷取目前裝置單例</code>
<code>+ (uidevice *)currentdevice;</code>
<code>//擷取目前裝置名稱 </code>
<code>@property(nonatomic,readonly,strong) nsstring *name; </code><code>// e.g. "my iphone"</code>
<code>//擷取目前裝置模式</code>
<code>@property(nonatomic,readonly,strong) nsstring *model; </code><code>// e.g. @"iphone", @"ipod touch"</code>
<code>//擷取本地化的目前裝置模式</code>
<code>@property(nonatomic,readonly,strong) nsstring *localizedmodel; </code><code>// localized version of model</code>
<code>//擷取系統名稱</code>
<code>@property(nonatomic,readonly,strong) nsstring *systemname; </code><code>// e.g. @"ios"</code>
<code>//擷取系統版本</code>
<code>@property(nonatomic,readonly,strong) nsstring *systemversion; </code><code>// e.g. @"4.0"</code>
<code>//擷取裝置方向</code>
<code>@property(nonatomic,readonly) uideviceorientation orientation; </code>
<code>//擷取裝置uuid對象</code>
<code>@property(nullable, nonatomic,readonly,strong) nsuuid *identifierforvendor;</code>
<code>//是否開啟監測電池狀态 開啟後 才可以正常擷取電池狀态</code>
<code>@property(nonatomic,getter=isbatterymonitoringenabled) </code><code>bool</code> <code>batterymonitoringenabled ns_available_ios(3_0); </code><code>// default is no</code>
<code>//擷取電池狀态</code>
<code>@property(nonatomic,readonly) uidevicebatterystate batterystate ns_available_ios(3_0); </code>
<code>//擷取電量</code>
<code>@property(nonatomic,readonly) </code><code>float</code> <code>batterylevel ns_available_ios(3_0);</code>
裝置方向的枚舉如下:
<code>typedef</code> <code>ns_enum(nsinteger, uideviceorientation) {</code>
<code> </code><code>uideviceorientationunknown,</code>
<code> </code><code>uideviceorientationportrait, </code><code>// home鍵在下</code>
<code> </code><code>uideviceorientationportraitupsidedown, </code><code>// home鍵在上</code>
<code> </code><code>uideviceorientationlandscapeleft, </code><code>// home鍵在右</code>
<code> </code><code>uideviceorientationlandscaperight, </code><code>// home鍵在左</code>
<code> </code><code>uideviceorientationfaceup, </code><code>// 螢幕朝上</code>
<code> </code><code>uideviceorientationfacedown </code><code>// 螢幕朝下</code>
<code>};</code>
電池狀态的枚舉如下:
<code>typedef</code> <code>ns_enum(nsinteger, uidevicebatterystate) {</code>
<code> </code><code>uidevicebatterystateunknown,</code>
<code> </code><code>uidevicebatterystateunplugged, </code><code>// 放電狀态</code>
<code> </code><code>uidevicebatterystatecharging, </code><code>// 充電未充滿狀态</code>
<code> </code><code>uidevicebatterystatefull, </code><code>// 充電已充滿</code>
下面的方法關于監測螢幕狀态:
<code>//擷取是否開啟螢幕狀态更改通知</code>
<code>@property(nonatomic,readonly,getter=isgeneratingdeviceorientationnotifications) </code><code>bool</code> <code>generatesdeviceorientationnotifications;</code>
<code>//開始監測通知</code>
<code>- (</code><code>void</code><code>)begingeneratingdeviceorientationnotifications; </code>
<code>//結束監測通知</code>
<code>- (</code><code>void</code><code>)endgeneratingdeviceorientationnotifications;</code>
<code>@property(nonatomic,getter=isproximitymonitoringenabled) </code><code>bool</code> <code>proximitymonitoringenabled ns_available_ios(3_0); </code><code>//開啟距離傳感器</code>
<code>//是否觸發了距離傳感器</code>
<code>@property(nonatomic,readonly) </code><code>bool</code> <code>proximitystate</code>
相關通知:
<code>//裝置方向改變時發送的通知</code>
<code>uikit_extern nsstring *</code><code>const</code> <code>uideviceorientationdidchangenotification;</code>
<code>//電池狀态改變時發送的通知</code>
<code>uikit_extern nsstring *</code><code>const</code> <code>uidevicebatterystatedidchangenotification ns_available_ios(3_0);</code>
<code>//電量改變時發送的通知</code>
<code>uikit_extern nsstring *</code><code>const</code> <code>uidevicebatteryleveldidchangenotification ns_available_ios(3_0);</code>
<code>//距離傳感器狀态改變時發送的通知</code>
<code>uikit_extern nsstring *</code><code>const</code> <code>uideviceproximitystatedidchangenotification ns_available_ios(3_0);</code>
<code></code>