[英]Landscape/Portrait conflict - iOS
就在我以为我想通了一切..我遇到了这个问题。
场景。
我有一个简单的tableView。 并在导航项的titleView中带有搜索栏。 SearchBar通过视图控制器工具栏中的uibarbuttonitem添加到navItems titleView。
现在,通常
用[beginResponder]启动搜索栏后,键盘出现。 然后它发出一个通知“ KeyboardDidShow”,这是我计算UIKeyboard的高度并相应地设置tableView的高度的地方(将其缩短)。
旋转时-往返风景/肖像时,一切正常。 -(void)didRotateInferfaceOrientation被调用,一切正常。
继承人的问题。
键盘处于活动状态时,它具有Google“搜索”按钮,此按钮会推至新视图-webviewcontroller。
问题是
何时,[PORTRAIT] ViewController [带键盘处于活动状态的SearchBar]->点击搜索-> [Portrait] WebViewController->将设备方向更改为[横向]-> [横向] WebViewController更改为横向--->这里问题,用户点击回到uiViewController [Landscape]
不会调用-didRotatefromInterfaceOrientation方法。 并且以某种方式将tableView高度弄乱了。 虽然视图旋转完美。
这里有什么我想念的吗..
将不胜感激。 。谢谢
当用户点击时,将不会调用-didRotatefromInterfaceOrientation。 您需要在viewWillAppear中检查方向(或在从背面轻按返回之前,调用viewDidLoad),然后为所选方向调用正确的布局。
在所有(BOOL)shouldRotate ...方法中,应调用一个单独的方法以确保布局与设备方向正确。
您可以在viewWillAppear上手动调用didRotateFromInterfaceOrientation,然后自己传递一个方向(即[UIApplication sharedApplication] .statusBarOrientation)。
我最近在我的一个应用程序中遇到了类似的问题,不完全是我们的问题,但不要打扰,您应该看到我要去的目标:我想简单地旋转一个使用presentModalViewController显示的viewController ...不幸的是,它没有确实有效,特别是在iOS 4之前的旧iPhone和OS上。。。所以我需要以编程方式旋转! 只要获取您的屏幕尺寸,使用CGAffineTransform或类似的方法并更改尺寸,然后就应该完成了...如果您有兴趣,我可以发布一堆代码,请告诉我!
编辑:
UIScreen *screen = [UIScreen mainScreen];
myController.view.bounds = CGRectMake(0, 0, screen.bounds.size.height, screen.bounds.size.width - 20);
if(currentOrientation == UIDeviceOrientationLandscapeRight){
myController.view.transform = CGAffineTransformConcat(myController.view.transform, CGAffineTransformMakeRotation(degreesToRadian(-90)));
}else{
myController.view.transform = CGAffineTransformConcat(myController.view.transform, CGAffineTransformMakeRotation(degreesToRadian(90)));
}
myController.view.center = window.center;
[[UIApplication sharedApplication] setStatusBarOrientation:currentOrientation];
[self.window addSubview:self.tabBarController.view];
[self.window bringSubviewToFront:self.tabBarController.view];
[self.window addSubview:myController.view];
[self.window bringSubviewToFront:myController.view];
[self.tabBarController.view removeFromSuperview];`
这还包括在旋转到横向时删除TabBar以获得更多空间...享受:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.