Get the phone's current version number
// Get hardware information Uidevice *device=[Uidevice currentdevice]; // output version number NSLog (@ "%@", device.systemversion);
Get Phone Directions
1 Notice
// The detection device faces the notification hub using the Uidevice,begingeneratingdeviceorientationnotifications method to send orientation information [[Uidevice currentdevice]begingeneratingdeviceorientationnotifications]; // Add notification object: nil];
2 Implementation Methods
-(void) orientationchanged: (Nsnotification *) notification{uideviceorientation orientation=[[Uidevice currentdevice]orientation]; Switch(orientation) { CaseUideviceorientationfaceup:nslog (@"device facing up"); Break; CaseUideviceorientationfacedown:nslog (@"Equipment face down"); Break; CaseUideviceorientationportrait:nslog (@"The device is in normal orientation and the home button is below"); Break; CaseUideviceorientationportraitupsidedown:nslog (@"device is in portrait, home button is above"); Break; CaseUideviceorientationlandscapeleft:nslog (@"device side stand, left facing down"); Break; CaseUideviceorientationlandscaperight:nslog (@"Device side stand, right face down"); Break; default: Break; }
Phone shake, beep, reminder
1 First import framework: Audiotoolbox, an excuse file for importing the framework in a file: #import <AudioToolbox/AudioToolbox.h>
Sound
-(Ibaction) ButtonClick: (UIButton *) Sender {//declare variable soundid, used to introduce sound filesSystemsoundid Soundid; //Get the sound file pathNSString *soundfile=[[nsbundle Mainbundle]pathforresource:@"SoundEffect"OfType:@"wav"]; //1. Bridging point to File location __bridge. Convert C language structure to OC Language objectAudioservicescreatesystemsoundid (__bridge cfurlref) [Nsurl Fileurlwithpath:soundfile], &Soundid); //play a warning toneAudioservicesplaysystemsound (Soundid);}
Cue tone
-(Ibaction) Alertbuttonclick: (UIButton *) Sender { Systemsoundid soundid; NSString *soundfile=[[nsbundle Mainbundle]pathforresource:@ "soundeffect" OfType:@ "wav" ]; Audioservicescreatesystemsoundid (__bridge cfurlref) [Nsurl Fileurlwithpath:soundfile], &// warning tones, Vibrate audioservicesplayalertsound (soundid) when the user adjusts to mute;}
Vibration
-(Ibaction) Shakebuttonclick: (UIButton *) Sender { Systemsoundid soundid; // regardless of cell phone status, only vibration audioservicesplaysystemsound (soundid);}
iphone device related