在横向重新加载视图后,UIWebView,SearchBar和TabBar没有正确调整大小?

时间:2013-06-30 15:10:09

标签: ios uiwebview uisearchbar uitabbar uitoolbar

我有一个tabbar应用程序,在一个选项卡中显示Web浏览器。当您旋转视图时,一切正常,但是当您切换到另一个选项卡,然后返回横向的该选项卡时,视图webview,搜索栏和工具栏将返回到纵向布局。这是我使用的代码,但它没有似乎工作:

#define isPortrait [[UIApplication sharedApplication] statusBarOrientation] ==     UIInterfaceOrientationPortrait || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown

if(isPortrait)
{
    browser.frame = CGRectMake(0, 68, 320, 408);
    addressBar.frame = CGRectMake(0, 23, 320, 44);
    toolBar.frame = CGRectMake(0, 478, 320, 44);
}
else
{
    browser.frame = CGRectMake(0, 68, 320, 408);
    addressBar.frame = CGRectMake(0, 23, 320, 44);
    toolBar.frame = CGRectMake(0, 478, 320, 44);
}

这完全在我的viewdidload方法中。

1 个答案:

答案 0 :(得分:0)

-(void)viewDidAppear:(BOOL)animated
{
    if (UIInterfaceOrientationIsLandscape([UIDevice currentDevice].orientation)) {
        browser.frame = CGRectMake(0, 68, 568, 160);
        addressBar.frame = CGRectMake(0, 23, 568, 44);
        toolBar.frame = CGRectMake(0, 227, 568, 44);
    }
}