iphone device related

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.