mam*_*mcx 7 iphone cocoa-touch ios
我有一个基于tabbar的应用程序.
我在Interface Builder中构建了2个视图,一个是纵向视图,另一个是横向模式.
现在,我想要像iPod应用程序.我想将横向视图设置为全屏,并隐藏标签栏和状态栏.
我的工作基础是:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration {
if (self.landscape) {
if (toInterfaceOrientation == UIInterfaceOrientationPortrait)
{
self.view = self.portrait;
self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(360));
}
else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)
{
self.view = self.landscape;
self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(-90));
}
else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
self.view = self.landscape;
self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
}
else
{
self.view = self.portrait;
self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(-180));
}
}
}
Run Code Online (Sandbox Code Playgroud)
但所有工作都很混乱.横向视图未正确填充区域,控件位于错误的位置,与首先设计的不同.
而且,我还没有找到隐藏其他一切的方法......
小智 5
查看Apple的"AlternateViews"示例代码.
基本思想是您可以通过通知检测设备的物理方向,然后"模态"激活新的视图控制器并让它请求全屏.您可以通过使用shouldAutorotate来禁用界面旋转...仅针对一个方向返回YES,因为您通过通知手动执行所有操作.更改物理方向时,会显示或取消模态视图控制器.
您可以通过调用隐藏状态栏
setStatusBarHidden:(BOOL)
Run Code Online (Sandbox Code Playgroud)
在 UIApplication 参考上,就像这样。
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[application setStatusBarHidden:YES];
}
Run Code Online (Sandbox Code Playgroud)
要摆脱标签栏,您可以在界面构建器中为您的代码创建一个引用出口并调用
[myUITabBar removeFromSuperview];
Run Code Online (Sandbox Code Playgroud)
这可能有用,虽然我还没有测试过,至于其他问题,我不是100%,之前没有解决过这些问题。
归档时间: |
|
查看次数: |
10569 次 |
最近记录: |