UITabBarController视图切换时,界面跳动

使用UITabBarController做根视图控制器, 且有些UIViewController隐藏UINavigationController时,在切换视图控制器时,会出现页面跳动情况。

原因在于设置隐藏或显示时,设置了动画为YES,如:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}

解决代码示例:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}

你可能感兴趣的:(页面跑步去,隐藏导航栏页面跳动,iOS,开发编码收集,iOS,开发问题集)