Some iPhone knowledge, remove statusbar, horizontal screen, gravity sensing, automatic switch portrait, boot screen landscape, boot screen landscape.

Source: Internet
Author: User

1. Remove statusbar.

Add uistatusbarhidin info. plist to set Boolean to yes.

2. Landscape Screen

Add uiinterfaceorientation in info. List to set uiinterfaceorientationlandscaperight.

3. Gravity sensing

Appdelegate inherits the uiaccelerometerdelegate protocol and implements

// Implement this method to get the lastest data from the accelerometer

-(Void) Accelerometer :( uiaccelerometer *) accelerometer didaccelerate :( uiacceleration *) Acceleration {

// Use a basic low-pass filter to only keep the gravity in the accelerometer values {}

In

-(Void) Applicationdidfinishlaunching :( uiapplication *) Application {

}

Add

// Configure and start Accelerometer

 [[Uiaccelerometer sharedaccelerometer] setupdateinterval :(1.0/Kaccelerometerfrequency)];

 [[Uiaccelerometer sharedaccelerometer] setdelegate:Self];

Gravity sensing can be realized.

4. automatic switch.

-(Bool) shouldautorotatetointerfaceorientation :( uiinterfaceorientation) interfaceorientation // supports Vertical Rotation
{

Return yes;
}
-(Void) willrotatetointerfaceorientation :( uiinterfaceorientation) tointerfaceorientation duration :( nstimeinterval) Duration // when rotation occurs
{
F (self. interfaceorientation = uiinterfaceorientationportrait | self. interfaceorientation = uideviceorientationportraitupsidedown)
{
// Vertical Steering
}
}
-(Void) didrotatefrominterfaceorientation :( uiinterfaceorientation) frominterfaceorientation // The rotation is completed.
{If (self. interfaceorientation = uiinterfaceorientationportrait | self. interfaceorientation = uideviceorientationportraitupsidedown)
{
// Currently in portrait Mode
}
}

Switching between landscape screens

-(Bool) Shouldautorotatetointerfaceorientation :(Uiinterfaceorientation)Interfaceorientation//Horizontal Vertical Rotation

{

If(Interfaceorientation=Uiinterfaceorientationlandscaperight)

{

Return Yes;

}

Else If(Interfaceorientation=Uiinterfaceorientationlandscapeleft)

{

Return Yes;

}

Return No;

}

//////////////////////////////////////// /////////////////////

The following has not been tested

Use gravity sensing to determine the direction of the phone and then set [uiapplication sharedapplication]. statusbarorientation = uiinterfaceorientationlandscaperight and uiinterfaceorientationportrait can be used to bring up a dialog box of landscape or portrait screen based on different phone directions. The keyboard containing the input box can also be automatically rotated in the dialog box.

//////////////////////////////////////// /////////////////////

5. Landscape Screen

Default-LandscapeLeft.png
Default-LandscapeRight.png
Default-Portrait.png
Default-PortraitUpsideDown.png

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.