whether the "1" inference is a horizontal screen:
BOOL B=uideviceorientationislandscape ([Uidevice currentdevice].orientation);
Get device uniqueidentifier:
[Uidevice Currentdevice].uniqueidentifier;
But in iOS5, it has been discarded.
http://kensou.blog.51cto.com/3495587/655083
[[Uidevice Currentdevice] systemName]; [[Uidevice Currentdevice] Systemversion];//os version[[uidevice currentdevice] uniqueidentifier]; [[Uidevice Currentdevice] model]; [[Uidevice Currentdevice] name];
True on-Machine results:
System Name:iphone OS
System version:4.2.1
Unique id:9b5ded78d5fa0ac96250f8b4af0e46f40b96ea6d
Model:iphone
Name: "Wwk" of the IPhone
Results on Simulator:
System Name:iphone OS
System version:4.2
Unique id:21ffe0ff-429b-5d0b-96d2-eadca3203260
Model:iphone Simulator
Name:iphone Simulator
Uniqueidentifier:iphone passed. Apply an internal hashing algorithm to several hardware identifiers and device serial numbers. and generate this identifier.
"2" battery event notification and battery status: The battery level is a floating point value, from 0.0 fully discharged, to 1.0 fully charged.
[nslog:@ "Battery Level:%0.2f%", [[Uidevice Currentdevice] batterylevel] * 100]; Nsarray *statearray = [Nsarray arraywithobjects: @ "Unknown", @ "not plugged to a charging source", @ "charging", @ "full", NIL]; [nslog:@ "Battery State:%@", [Statearray objectatindex:[[uidevice Currentdevice] batterystate]];
Get a lot of other device information: Use Sysctlbyname (), sysctl () standard UNIX functions.
Some device information constants are provided in Sys/sysctl.h. Be aware that you want # include <sys/socket.h> first.
For a detailed reference, cheats 2 14.3 Again gets a lot of other device information.
The value of Hw.machine, the first-generation iphone is (iphone1,1). IPHONE3G is (iphone1,2). IPHONE3GS is (iphone2,1), x86_64 on the simulator.
"3". Sensor.
When the proximity sensor is enabled, it detects if there is a large object in front of it, which is false. It will turn off the screen and issue a general notification. When the obstacle is removed, the screen is opened again. This prevents misuse of the ear to touch the button during notification.
Also prevent some protective cases from affecting the sensor work.
[Uidevice Currentdevice].proximitymonitoringenabled=yes; [[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (handlestatechange:) name:@ " Uideviceproximitystatedidchangenotification "Object:nil";
"4" acceleration.
On a measured speed, the iphone offers 3 onboard sensors. They measure acceleration along the iphone's vertical axis in 3 direction xyz. These values represent the force that affects the iphone.
[[Uiaccelerometer Sharedaccelerometer] setdelegate:self];//uiaccelerometerdelegate -(void) Accelerometer: ( Uiaccelerometer *) Accelerometer didaccelerate: (uiacceleration *) acceleration{ float xx =-[acceleration x]; float yy = [acceleration y]; float angle = atan2 (yy, xx); [Arrow settransform:cgaffinetransformmakerotation (angle)];}
"5" Test device direction: horizontal or vertical.
[[Uidevice Currentdevice] begingeneratingdeviceorientationnotifications]; Not actually required but a good idea in case Apple changes this [[Nsnotificationcenter Defaultcenter] Addobserver: Self selector: @selector (orientationchanged:) name:uideviceorientationdidchangenotification object:nil];// Rewrite shouldautorotatetointerfaceorientation-(BOOL) shouldautorotatetointerfaceorientation in Viewcontroller: ( uiinterfaceorientation) anorientation{ return (anorientation = = Uideviceorientationportrait | | Anorientation = = Uideviceorientationlandscaperight | | Anorientation = = Uideviceorientationlandscapeleft | |); iphone is not recommended for use with uideviceorientationportraitupsizedown}-(void) orientationchanged: (ID) sender{ NSLog (@ " Orientation changed to%@ ", [Uidevice currentdevice].orientationstring);//Current device orientation}// Two built-in macro-assisted inference direction uideviceorientationisportrait (anorientation) uideviceorientationislandscape (anorientation)
"6" shaking test shakedetection.
Response chain: The response chain provides a hierarchical object, an event that is received by the object at the beginning. It will not be passed down again. Otherwise, continue to pass down.
The object is generally passed [self becomefirstresponder]; declares itself to be the first responder. [self resignfirstresponder]; Declaration exits first Responder.
The first responder receives all the motion and touch events.
-(BOOL) Canbecomefirstresponder {return YES;}
For example, the following 3 motion callback functions can be overridden, and they are defined in Uiresponder:
-(void) Motionbegan: (uieventsubtype) Motion withevent: (uievent *) event -(void) motionended: (Uieventsubtype) Motion withevent: (uievent *) event
"7" Disk space
Nsfilemanager *FM = [Nsfilemanager Defaultmanager]; Nsdictionary *fattributes = [FM filesystemattributesatpath:nshomedirectory ()]; System space:[[fattributes objectforkey:nsfilesystemsize] longlongvalue]; System free space: [[Fattributes objectforkey:nsfilesystemfreesize] longlongvalue];
"8" itunes through the list of device features listed in Info.plist. Determine if a program can be downloaded to the specified device and executed properly.
"9" In the AVAILABILITY.h file has a version number macro definition, such as: __iphone_4_2
Is this OS version or SDK version, or are they the same?
Http://www.opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/Availability.h
"10"
nsstring* Udid=[[uidevice Currentdevice] uniqueidentifier]; return udid;
"11"
Instead, a button is used in the topmost layer to respond to the Click event */else { nsstring* systemversion=[[uidevice currentdevice] systemversion]; float floatversion=[systemversion Floatvalue]; NSLog (@ "systemversion:%@,floatversion:%f", systemversion,floatversion); if (floatversion<5.0) { //in ios5. Each layer UIView will respond to touchesended, so the ios5 does not have to be raised here. ret=[(viewgroupwrap*) isuperviewwrap Handletouch]; } } */
"12" coding different ways to differentiate iphone ipod & ipad
(1) Use UI_USER_INTERFACE_IDIOM () to differentiate
Ui_user_interface_idiom () = = Uiuserinterfaceidiompad //ipadui_user_interface_idiom () = = Uiuserinterfaceidiomphone //iphone
(2) using Uidevice.model to differentiate
NSString *devicetype = [Uidevice currentdevice].model; if ([DeviceType isequaltostring:@ "IPhone"]) { //iphone } else if ([DeviceType isequaltostring:@ "IPod Touch "]) { //ipod touch } else { //ipad }
(3) Use a function sysctlbyname of the system to get the device name
-(NSString *) platformstring{size_t size; Sysctlbyname ("Hw.machine", NULL, &size, NULL, 0); Char *machine = malloc (size); Sysctlbyname ("Hw.machine", Machine, &size, NULL, 0); NSString *platform = [NSString stringwithutf8string:machine]; Free (machine); if ([Platform isequaltostring:@ "iphone1,1"]) return @ "IPhone 1G"; if ([Platform isequaltostring:@ "iphone1,2"]) return @ "IPhone 3G"; if ([Platform isequaltostring:@ "iphone2,1"]) return @ "IPhone 3GS"; if ([Platform isequaltostring:@ "iphone3,1"]) return @ "IPhone 4"; if ([Platform isequaltostring:@ "iphone3,3"]) return @ "Verizon IPhone 4"; if ([Platform isequaltostring:@ "ipod1,1"]) return @ "IPod Touch 1G"; if ([Platform isequaltostring:@ "ipod2,1"]) return @ "IPod Touch 2G"; if ([Platform isequaltostring:@ "ipod3,1"]) return @ "IPod Touch 3G"; if ([Platform isequaltostring:@ "ipod4,1"]) return @ "IPod Touch 4G"; if ([Platform isequaltostring:@ "ipad1,1"]) return @ "IPad"; if ([Platform isequaltostring:@ "ipad2,1"]) return @ "IPad 2 (WiFi)"; if ([Platform isequaltostring:@ "ipad2,2"]) return @ "IPad 2 (GSM)"; if ([Platform isequaltostring:@ "ipad2,3"]) return @ "IPad 2 (CDMA)"; if ([Platform isequaltostring:@ "i386"]) return @ "Simulator"; return @ "";}
References http://hi.baidu.com/songxiaoweiss/blog/item/c78162f869fc148c58ee9028.html
"13" About getting IMSI number
Coretelephony.framework.
Header file Contents
extern nsstring* c*****t Kctsmsmessagereceivednotification;extern nsstring* c*****t Kctsmsmessagereplacereceivednotification;extern nsstring* c*****t Kctsimsupportsimstatusnotinserted;extern nsstring* c*****t Kctsimsupportsimstatusready; ID cttelephonycentergetdefault (void); void Cttelephonycenteraddobserver (id,id,cfnotificationcallback,nsstring*, Void*,int); void Cttelephonycenterremoveobserver (id,id,nsstring*,void*); int ctsmsmessagegetunreadcount (void); int ctsmsmessagegetrecordidentifier (void * msg); NSString * Ctsimsupportgetsimstatus (); Gets the status of the SIM card. Kctsimsupportsimstatusnotinserted means no SIM card NSString * ctsimsupportcopymobilesubscriberidentity (); Get IMSI number ID ctsmsmessagecreate (void* unknow/*always 0*/,nsstring* number,nsstring* text); void * Ctsmsmessagecreatereply (void* unknow/*always 0*/,void * forwardto,nsstring* text); void* ctsmsmessagesend (ID server,id msg); NSString *ctsmsmessagecopyaddress (void *, void *); NSString *ctsmsmessagecopytext (void *, void *);
Call Ctsimsupportcopymobilesubscriberidentity can successfully get to the IMSI number
Use Performselector to escape the apple test.
"iOS Development Series" Uidevice device information