1, remove StatusBar
In Info.plist Add Uistatusbarhidden set Boolean, set to Yes.
2, Horizontal screen
Continue adding uiinterfaceorientation settings in info.list uiinterfaceorientationlandscaperight Xcode 4.3.2 for inital interface Orientation set to Landscape (right home button) of course you input the above, Xcode will also correct for you, so both can!
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 to
Configure and start Accelerometer
[[Uiaccelerometer Sharedaccelerometer] Setupdateinterval: (1.0/kaccelerometerfrequency)];
[[Uiaccelerometer Sharedaccelerometer] setdelegate:self];
We can achieve gravity sensing.
4, automatically switch between the vertically.
-(BOOL) Shouldautorotatetointerfaceorientation: (uiinterfaceorientation) interfaceorientation//Support rotation
{
return YES;
}
-(void) Willrotatetointerfaceorientation: (uiinterfaceorientation) tointerfaceorientation Duration: (NSTimeInterval ) duration//When rotation occurs
{
F (self.interfaceorientation==uiinterfaceorientationportrait| | Self.interfaceorientation==uideviceorientationportraitupsidedown)
{
Horizontal Steering Vertical
}
}
-(void) Didrotatefrominterfaceorientation: (uiinterfaceorientation) frominterfaceorientation//rotation complete
{if (self.interfaceorientation==uiinterfaceorientationportrait| | Self.interfaceorientation==uideviceorientationportraitupsidedown)
{
It is currently in vertical screen mode
}
}
Toggle between horizontal Screens
-(BOOL) Shouldautorotatetointerfaceorientation: (uiinterfaceorientation) interfaceorientation//Support rotation
{
if (interfaceorientation = = uiinterfaceorientationlandscaperight)
{
return YES;
}
else if (interfaceorientation = = Uiinterfaceorientationlandscapeleft)
{
return YES;
}
return NO;
}
/////////////////////////////////////////////////////////////
The following has not been tested
Using gravity sensing, determine the direction of the phone, and then Set [uiapplication sharedapplication].statusbarorientation = Uiinterfaceorientationlandscaperight, As well as uiinterfaceorientationportrait, can be done according to the direction of the different mobile phone pop-up or Vertical screen dialog box, including the dialog box containing the input box keyboard can also be automatically rotated
/////////////////////////////////////////////////////////////
5, power on screen horizontal screen
Default-landscapeleft.png
Default-landscaperight.png
Default-portrait.png
Default-portraitupsidedown.png
Gravity Sensor screen Switch