iphone一些知识,去掉StatusBar,横屏,重力感应,自动切换横竖,开机画面横屏,开机画面横屏。

http://www.cnblogs.com/APTX4869/archive/2011/02/24/1963527.html
1,去掉StatusBar

在info.plist添加UIStatusBarHidden设置Boolean,设置为YES.

2,横屏

继续在info.list中添加UIInterfaceOrientation 设置UIInterfaceOrientationLandscapeRight

3,重力感应

AppDelegate继承UIAccelerometerDelegate协议,并实现

// 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{}



- (void)applicationDidFinishLaunching:(UIApplication *)application {


}

添加

//Configure and start accelerometer

[[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / kAccelerometerFrequency)];

[[UIAccelerometer sharedAccelerometer] setDelegate:self];

就可以实现重力感应

4,自动切换横竖。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation //支持横 竖转动
{

return YES;
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration //当发生旋转 时
{
f(self.interfaceOrientation==UIInterfaceOrientationPortrait||self.interfaceOrientation==UIDeviceOrientationPortraitUpsideDown)
{
//横 转向 竖
}
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation //旋转 完成
{          if(self.interfaceOrientation==UIInterfaceOrientationPortrait||self.interfaceOrientation==UIDeviceOrientationPortraitUpsideDown)
{
//当前是在竖屏模式
}
}

横屏之间切换

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation //支持横 竖转动

{

if (interfaceOrientation == UIInterfaceOrientationLandscapeRight )

{

return YES;

}

else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft)

{

return YES;

}

return NO;

}

/

以下未经过测试

使用重力感应,判断手机的方向,然后设定[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight,以及UIInterfaceOrientationPortrait,就可以做到根据不同的手机方向弹出横屏还是竖屏的对话框了,包括对话框上包含输入框的键盘也可以自动旋转了

/

5,开机画面横屏

Default-LandscapeLeft.png
Default-LandscapeRight.png
Default-Portrait.png
Default-PortraitUpsideDown.png
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值