所述的UIWindow的后台应用程序在视图的顶部跳跃当我从一个视图内容切换到一个UITableVie

2019-10-22 05:50发布

我负责更新iOS8上的应用程序。 但我有一个问题,当我想两个视图(新,旧)之间切换。 在一个UIWindow的应用程序的背景跃升。 它在1秒期间和消失出现。 我无法找到问题。 我点击一个后退按钮来更改内容视图。

- (void)onBackTap
    {
        NSLog(@"Standard back");

        [self goBackWithAnimation:AnimatePushFromLeft];
    }


- (void)goBackWithAnimation:(GraphNavigationAnimation)animation
    {
        NSLog(@"History Before ---> %@", [self currentHistory]);

        [[self currentHistory] removeLastObject];
        NSLog(@"History After ---> %@", [self currentHistory]);

        self.currentVC = [[self currentHistory] lastObject];

        [view_ switchContentViewTo:currentVC_.view
            navigationItemStack:[[self currentHistory] valueForKey:@"navigationItem"]
            isNavbarVisible:navbarVisible_
            animation:animation];

    }

感谢您对我们的支持,如果你已经找到了解决办法。

这是我的程序从旧的和新的内容查看切换:

-(void)switchContentViewTo:(UIView *)newView navigationItemStack:(NSArray*)navigationItemStack isNavbarVisible:(BOOL)isNavbarVisible animation:GraphNavigationAnimation)animation {
    BOOL isPrevNavbarVisible = navbarVisible_;
    navbarVisible_ = isNavbarVisible;

    if (!contentView_) {
        contentView_ = newView;
        [self insertSubview:contentView_ belowSubview:navbar_];
        [navbar_ setItems:navigationItemStack animated:NO];

        [self setNeedsLayout];
        return;
    }

    if (newView == contentView_) {
        [navbar_ setItems:navigationItemStack animated:NO];
        return;
    }

    CGRect const bigFrame = self.bounds;
    CGRect const smallFrame = CGRectMake(0, navbarHeight_,
        self.bounds.size.width, self.bounds.size.height - navbarHeight_);

    CGRect centerFrame = isNavbarVisible
        ? smallFrame
        : bigFrame;

    void (^step1)(void) = ^{
        CGRect newViewStartFrame;
        switch (animation) {
            case AnimatePushFromRight: {
                newViewStartFrame = CGRectOffset(centerFrame, contentView_.bounds.size.width, 0);
                break;
            }
            case AnimatePushFromLeft: {
                newViewStartFrame = CGRectOffset(centerFrame, -contentView_.bounds.size.width, 0);
                break;
            }
            default:
                newViewStartFrame = centerFrame;
                break;
        }

        navbar_.hidden = !isNavbarVisible && !isPrevNavbarVisible;
        if (isNavbarVisible && !isPrevNavbarVisible) {
            navbar_.frame = CGRectMake(newViewStartFrame.origin.x, 0,
                newViewStartFrame.size.width, navbarHeight_);
        }

        newView.frame = newViewStartFrame;
        [self insertSubview:newView belowSubview:navbar_];
        self.userInteractionEnabled = NO;
        animating_ = YES;
    };

    void (^step2)(void) = ^{
        CGRect oldViewFinishFrame;
        switch (animation) {
            case AnimatePushFromRight: {
                oldViewFinishFrame = CGRectOffset(
                    contentView_.frame, -contentView_.bounds.size.width, 0);
                break;
            }
            case AnimatePushFromLeft: {
                oldViewFinishFrame = CGRectOffset(
                    contentView_.frame, contentView_.bounds.size.width, 0);
                break;
            }
            default:
                oldViewFinishFrame = contentView_.frame;
                break;
        }
        if (!isNavbarVisible && isPrevNavbarVisible) {
            navbar_.frame = CGRectMake(oldViewFinishFrame.origin.x, 0,
                oldViewFinishFrame.size.width, navbarHeight_);
        } else {
            navbar_.frame = CGRectMake(centerFrame.origin.x, 0,
                centerFrame.size.width, navbarHeight_);
        }
        newView.frame = centerFrame;
        contentView_.frame = oldViewFinishFrame;

    };

    void (^step3)(void) = ^{
        [contentView_ removeFromSuperview];
        contentView_ = newView;

        self.userInteractionEnabled = YES;
        animating_ = NO;
    };

    [navbar_ setItems:navigationItemStack animated:(animation != AnimateNone)];
    step1();
    [UIView animateWithDuration:(animation != AnimateNone ? animationDuration : 0)
                          delay:0.0
                         options:UIViewAnimationOptionCurveEaseInOut
                     animations:^{
                         step2();

                     }
        completion:^(BOOL finished){
            step3();
        }];
}
文章来源: The UIWindow's background application is jumping at the top of views when I switch from a view content to a UITableView