objective-c - 恢复 iOS7 之前的 UINavigationController p

所以。刚开始将我的 IOS 代码转换到 IOS7,遇到了一些问题。

我有一个 UINavigationController,它有子 ViewControllers,我正在使用 pushViewController 来显示下一个 View 。要使用一组图像创建视差动画,如果自定义 UINavigationController 以动画一组 UIImageViews 并且我的子 ViewControllers 都有一个 self.backgroundColor = [ UIColor clearColor],透明度。

从 iOS7 开始,UINavController 对其子 vc 的动画方式进行了更新,通过部分移动当前 View Controller 并在顶部推送新的 View Controller ,我的视差动画看起来很糟糕。我看到之前的 VC 移动了一下,然后消失了。有什么办法可以恢复以前的 UINavigationController pushViewController 动画?我似乎在代码中找不到这个。

WelcomeLoginViewController* welcomeLoginViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"WelcomeLogin"];
    [self.navigationController pushViewController:welcomeLoginViewController animated:YES];    

甚至尝试使用:

    [UIView animateWithDuration:0.75
                     animations:^{
                         [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
                         [self.navigationController pushViewController:welcomeLoginViewController animated:NO];
                         [UIView setAnimationTransition:<specific_animation_form> forView:self.navigationController.view cache:NO];
                     }];

有人知道吗?

最佳答案

我设法通过为 UINavigationController 创建一个类别来解决新的过渡类型。在我的情况下,我需要将其恢复为旧的过渡样式,因为我有透明的 viewControllers 可以在静态背景上滑动。

  • UINavigationController+Retro.h

    @interface UINavigationController (Retro)
    
    - (void)pushViewControllerRetro:(UIViewController *)viewController;
    - (void)popViewControllerRetro;
    
    @end
    
  • UINavigationController+Retro.m

    #import "UINavigationController+Retro.h"
    
    @implementation UINavigationController (Retro)
    
    - (void)pushViewControllerRetro:(UIViewController *)viewController {
        CATransition *transition = [CATransition animation];
        transition.duration = 0.25;
        transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
        transition.type = kCATransitionPush;
        transition.subtype = kCATransitionFromRight;
        [self.view.layer addAnimation:transition forKey:nil];
    
        [self pushViewController:viewController animated:NO];
    }
    
    - (void)popViewControllerRetro {
        CATransition *transition = [CATransition animation];
        transition.duration = 0.25;
        transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
        transition.type = kCATransitionPush;
        transition.subtype = kCATransitionFromLeft;
        [self.view.layer addAnimation:transition forKey:nil];
    
        [self popViewControllerAnimated:NO];
    }
    
    @end
    

关于objective-c - 恢复 iOS7 之前的 UINavigationController pushViewController 动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18867248/

相关文章:

ios - 在objective-c中导入swift类,-Swift.h文件未找

objective-c - 'pod install' 不会更新现有的 pod

objective-c - 适合 UILabel 中的文本

iphone - 什么是-[NSString sizeWithFont :forWidth:line

iphone - animateWithDuration :animations: block ma

objective-c - 使用自动布局自定义纵横比

ios - 计算两个 CLLocationCoordinate2D 之间的方位

objective-c - Objective C 中的多个委托(delegate)

iphone - UITableView/UITableViewCell 点击事件响应?

iphone - 如何使用第一个字符作为部分名称