强制旋转iPhone界面
2012-05-13 15:27
169 查看
在现在的ios sdk中,我们一般通过UIApplication的setStatusBarOrientation:来进行View的强制旋转
(当然,还要配合- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation),
但是,setStatusBarOrientation并不一定马上会执行shouldAutorotateToInterfaceOrientation进行界面旋转,
这时,有个小技巧可以让界面马上旋转过来,那就是调用一下 UINavigationController的presentModalViewController:animated:
{
//为了马上旋转过来
UINavigationController* nav = [[GurgleAppDelegate getAppDelegate] navigationController];
UIViewController *controller = [[UIViewController alloc] init];
UINavigationController *parentController = [[UINavigationController alloc] initWithRootViewController:controller];
[nav presentModalViewController:parentController animated:NO];
[controller dismissModalViewControllerAnimated:NO];
[parentController release];
[controller release];
}
// Override to allow orientations other than the default portrait orientation
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
return viewOrientation == interfaceOrientation;
}
注意:这样做导航栏会消失,但是可以通过自定义导航栏来显示导航的效果
(当然,还要配合- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation),
但是,setStatusBarOrientation并不一定马上会执行shouldAutorotateToInterfaceOrientation进行界面旋转,
这时,有个小技巧可以让界面马上旋转过来,那就是调用一下 UINavigationController的presentModalViewController:animated:
{
//为了马上旋转过来
UINavigationController* nav = [[GurgleAppDelegate getAppDelegate] navigationController];
UIViewController *controller = [[UIViewController alloc] init];
UINavigationController *parentController = [[UINavigationController alloc] initWithRootViewController:controller];
[nav presentModalViewController:parentController animated:NO];
[controller dismissModalViewControllerAnimated:NO];
[parentController release];
[controller release];
}
// Override to allow orientations other than the default portrait orientation
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
return viewOrientation == interfaceOrientation;
}
注意:这样做导航栏会消失,但是可以通过自定义导航栏来显示导航的效果
相关文章推荐
- 强制iphone界面马上旋转(转载)
- 强制iphone界面马上旋转
- ios 强制某个界面旋转成横屏
- iOS开发中控制屏幕旋转,个别界面强制横屏
- ipad/iphone ,adjust your layout when orientation will be changing , 旋转屏幕时调整界面布局
- ios 强制某个界面旋转成横屏
- 在iPhone任何界面截图完整图文教程
- 移动端上传图片iphone图片旋转以及服务端处理方法
- ios7禁止屏幕旋转,强制竖屏
- 吸墨网iPhone手机客户端界面设计
- iPad、iPhone界面元素设计标准(简洁版)
- 全代码编写的iPhone界面源码1 UIView UILabel UIButton
- 【iphone游戏开发】iphone-Cocos2d游戏开发之四:精灵实现缩放,旋转,跳动,移动等动画
- 【IOS学习】设置某个界面强制横屏,进入就横屏的几种方法
- iPhone第二节:登录、通讯录界面
- iOS手动控制界面旋转
- iphone练习之手势识别(双击、捏、旋转、拖动、划动、长按)UITapGestureRecognizer
- Iphone和ipad的GUi 界面设计风格
- 两种 iPhone 界面的动画效果
- qt界面窗口旋转90度显示