ios - 自定义 Segue NavBar 后退按钮

标签 ios segue

我想使用 NavBar 中的“后退”按钮从我的目标 View Controller 返回到源 View Controller 的自定义 segue。这可能吗?我无法在任何地方找到答案。

到目前为止,我将自定义 segue 从目标 View Controller 连接回源 View Controller 并添加下面的代码。但是,后退按钮不会触发我的自定义转场。

-(void)perform
{

    UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
    UIViewController *destinationController = (UIViewController*)[self destinationViewController];

    CATransition* transition = [CATransition animation];
    transition.type = kCATransitionMoveIn;
    transition.subtype = kCATransitionFromTop;
    transition.duration = 0.5;

    [sourceViewController.navigationController.view.layer addAnimation:transition forKey:kCATransition];
    [sourceViewController.navigationController pushViewController:destinationController animated:NO];
}

最佳答案

当推送 View Controller 从导航堆栈中弹出时,自定义从推送 View Controller 返回的过渡的方法是使用自定义过渡,这是 iOS 7 中的一项新功能。(在 iOS 7 之前,这是基本上不可能。)

关于ios - 自定义 Segue NavBar 后退按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22275585/

相关文章:

ios - viewDidLoad : Checking if from a segue?

iOS UITableView 无法为每个单元格计算正确的单元格高度

ios - 在 UITableView 中水平滚动以查看 Xcode 6 和 Swift 中的长单元格

ios - 连接表单文本字段的下一个字段链

objective-c - 根据 segue 标识符执行 dismissModalViewControllerAnimated 或 popViewControllerAnimated?

ios - 如何为 segue 呈现的 View Controller 实现委托(delegate)?

ios - 将 TableView 的所有数据转换为 CollectionView 快速解析

ios - Storyboard ViewController.m

ios - 编译错误 : #error "This file should be compiled in ARM mode only."

ios - 如何在不下载外部 URL 的情况下测试文件是否存在?