iOS Ausblenden der tab-Leiste in iOS 6 erstellt schwarze Balken (fix für iOS 6 bricht iOS 7!)

Habe ich eine Anwendung im Registerkartenformat und in einem tab gibt es eine UIWebView. Wenn ich drehen Sie das Gerät ins Querformat, ich habe die UIWebView Vollbild beim verstecken des status-und tab-Leiste.

Ich habe es in iOS 6, die ursprünglich beim drehen und ausblenden der tab-Leiste, es würde verlassen einen schwarzen Raum, wo die tab-bar war, so dass die fHeight code behebt dieses. Aber auf iOS 6 funktionierte es perfekt, aber jetzt ist es tatsächlich schafft, die schwarze Balken, problem iOS 6 hatte!! Irgendwelche Ideen für einen workaround dazu?

Bitte siehe mein edit unter diesem

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;
{
    if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
        [self hideTabBar:self.tabBarController];
        [[UIApplication sharedApplication] setStatusBarHidden:TRUE withAnimation:UIStatusBarAnimationSlide];
    }
    else
    {
        [self showTabBar:self.tabBarController];
        [[UIApplication sharedApplication] setStatusBarHidden:FALSE withAnimation:UIStatusBarAnimationSlide];
    }
}

- (void) hideTabBar:(UITabBarController *) tabbarcontroller
{
    CGRect screenRect = [[UIScreen mainScreen] bounds];

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.5];
    float fHeight = screenRect.size.height;
    if(  UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation) )
    {
        fHeight = screenRect.size.width;
    }

    for(UIView *view in self.tabBarController.view.subviews)
    {
        if([view isKindOfClass:[UITabBar class]])
        {
            [view setFrame:CGRectMake(view.frame.origin.x, fHeight, view.frame.size.width, view.frame.size.height)];
        }
        else
        {
            [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, fHeight)];
            view.backgroundColor = [UIColor blackColor];
        }
    }
    [UIView commitAnimations];
}

- (void) showTabBar:(UITabBarController *) tabbarcontroller
{
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    float fHeight = screenRect.size.height - 49.0;

    if(  UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation) )
    {
        fHeight = screenRect.size.width - 49.0;
    }

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.5];
    for(UIView *view in tabbarcontroller.view.subviews)
    {
        if([view isKindOfClass:[UITabBar class]])
        {
            [view setFrame:CGRectMake(view.frame.origin.x, fHeight, view.frame.size.width, view.frame.size.height)];
        }
        else
        {
            [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, fHeight)];
        }
    }
    [UIView commitAnimations];
}

//Edit

Ich habe versucht, mit diesem aber ich bin mir nicht sicher, wie Sie Sie übergeben in der Ansicht richtig - ich habe versucht self.view und webView und andere, aber ich nicht bekommen kann es arbeiten auf beiden iOS 6 und 7! Jede Art von Idee wäre wirklich hilfreich!!! Lassen Sie mich wissen, wenn Sie weitere Informationen benötigen

- (void)setTabBarHidden:(BOOL)hidden view:(UIView *)view animated:(BOOL)animated
{
    if (self.tabBar.hidden == hidden)
        return;

    CGRect screenRect = [[UIScreen mainScreen] bounds];
    float height = 0.0f;

    if(UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation))
    {
        height = screenRect.size.width;
    }
    else
    {
        height = screenRect.size.height;
    }

    if (!hidden)
    {
        height -= CGRectGetHeight(self.tabBar.frame);
    }

    void (^workerBlock)() = ^() {

        self.tabBar.frame = CGRectMake(CGRectGetMinX(self.tabBar.frame), height, CGRectGetWidth(self.tabBar.frame), CGRectGetHeight(self.tabBar.frame));
        view.frame = CGRectMake(CGRectGetMinX(view.frame), CGRectGetMinY(view.frame), CGRectGetWidth(view.frame), height);
    };

    void (^completionBlock)(BOOL finished) = ^(BOOL finished) {
        self.tabBar.hidden = hidden;
    };

    if (animated)
    {
        [UIView animateWithDuration:0.25f animations:workerBlock completion:completionBlock];
    }
    else
    {
        workerBlock();
        completionBlock(YES);
    }
}
InformationsquelleAutor Chris Byatt | 2013-09-25
Schreibe einen Kommentar