【问题标题】:TableView split animation segueTableView 分割动画segue
【发布时间】:2013-08-29 15:18:46
【问题描述】:

我正在开发一个应该像这样工作的自定义动画转场:

User taps cell in table view,
table view splits underneath the selected cell,
bottom half translates down, upper half translates up to reveal destination view

不幸的是,我在将视图分成两部分时遇到了麻烦。我的想法是创建两个视图快照,然后更改这些快照的边界,一个代表底部,一个代表顶部,将视图隐藏在下面,然后转换快照。

但是,有两个问题:1)如果源视图隐藏或更改 alpha,快照也会更改(因为拍摄快照的唯一方法是使它们成为源视图的子视图)。和 2) 目标视图在黑屏后显示较晚。

关于问题是什么的任何想法?或者也许是一个新的方向?

代码如下:

@interface ExpandTableViewSegue()

// there are these also in header
// UIImageView *topView;
// UIImageView *bottomView;

@property (strong, nonatomic) UIView *containerView;
@property (strong, nonatomic) UIViewController *imageContainerViewController;

@property (strong, nonatomic) UIView *backgroundView;

@property (strong, nonatomic) UINavigationController *navigationController;

@end

@implementation ExpandTableViewSegue


- (void)perform {
    self.navigationController = [self.sourceViewController navigationController];

    [self pushDestinationControllerToNavigationStack];
    self.backgroundView = [[self.destinationViewController view] snapshotView];
    [self popTopMostControllerOffStack];

    [self pushImageContainerControllerToNavigationStack];
    [self animateImagesInContainerView];
}

- (void)pushDestinationControllerToNavigationStack {
    [self.navigationController pushViewController:self.destinationViewController animated:NO];
}

- (void)pushImageContainerControllerToNavigationStack {
    UIViewController *imageContainerController = [self imageContainerViewController];

    [self.navigationController pushViewController:imageContainerController animated:NO];
}

- (void)animateImagesInContainerView {
    [UIView animateWithDuration:2.0 delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^{

        [[self.sourceViewController view]removeFromSuperview];
        [self translateTopImageUp];
        [self translateBottomImageDown];
        [self.containerView removeFromSuperview];
    }
    completion:^(BOOL finished) {
        if (finished) {
            [self popTopMostControllerOffStack];
            [self pushDestinationControllerToNavigationStack];
        }
    }];
}

EDIT1:(更新代码)我解决了第一个问题......我所做的是创建一个容器视图,其中包含两个快照图像,然后在执行动画之前将该视图推送到导航堆栈。 但是我仍然遇到第二个问题,它处理目标控制器何时被推入堆栈。我想要的是让动画在下面逐渐显示目标视图。但现在它显示黑屏(当前视图),然后弹出到目标视图。

我尝试的解决方案是快速将目标视图推送到堆栈中,拍摄快照,然后将其从堆栈中弹出。 然后继续该过程,但将新快照添加到背景中,使其出现在前两个快照的后面。

有什么新想法吗?谢谢!

【问题讨论】:

  • 你能在这里更新代码吗,你是如何拆分tableview的

标签: ios objective-c core-animation uistoryboardsegue


【解决方案1】:

你有一个很好的方法。我会拍摄快照,然后将它们传递给 -prepareForSegue: 方法中的destinationViewController。让destinationViewController 处理它们,并在动画完成后将它们移除。 或者,如果您将图像子类化,则可以将图像传递给 segue。

【讨论】:

  • 感谢您的意见!我现在将顶部和底部图像从 sourceviewcontroller 发送到 segue 子类,然后 segue 处理动画。
猜你喜欢
  • 1970-01-01
  • 2013-05-02
  • 1970-01-01
  • 1970-01-01
  • 2013-02-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多