Saya punya satu masalah dan saya telah menjelaskannya di bawah ini.
Saya menggunakan UIViewControllerContextTransitioning
untuk transisi khusus.
Saya memiliki 2 pengontrol tampilan, pengontrol tampilan pertama dan pengontrol tampilan kedua.
Sekarang saya ingin menambahkan pengontrol tampilan kedua pada pengontrol tampilan pertama dengan animasi. Saya telah mencapainya, sekarang pengontrol tampilan kedua transparan, jadi kita bisa melihat pengontrol tampilan pertama di bawah pengontrol tampilan kedua.
Tetapi saya tidak dapat melihat pengontrol tampilan pertama, dan saya hanya dapat melihat layar hitam di bawah pengontrol tampilan kedua.
-(void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext{
self.transitionContext = transitionContext;
if(self.isPresenting){
[self executePresentationAnimation:transitionContext];
}
else{
[self executeDismissalAnimation:transitionContext];
}
}
-(void)executePresentationAnimation:(id<UIViewControllerContextTransitioning>)transitionContext{
UIView* inView = [transitionContext containerView];
UIViewController* toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
UIViewController* fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
CGRect offScreenFrame = inView.frame;
offScreenFrame.origin.y = inView.frame.size.height;
toViewController.view.frame = offScreenFrame;
toViewController.view.backgroundColor = [UIColor clearColor];
fromViewController.view.backgroundColor = [UIColor clearColor];
inView.backgroundColor = [UIColor clearColor];
[inView insertSubview:toViewController.view aboveSubview:fromViewController.view];
// [inView addSubview:toViewController.view];
CFTimeInterval duration = self.presentationDuration;
CFTimeInterval halfDuration = duration/2;
CATransform3D t1 = [self firstTransform];
CATransform3D t2 = [self secondTransformWithView:fromViewController.view];
[UIView animateKeyframesWithDuration:halfDuration delay:0.0 options:UIViewKeyframeAnimationOptionCalculationModeLinear animations:^{
[UIView addKeyframeWithRelativeStartTime:0.0f relativeDuration:0.5f animations:^{
fromViewController.view.layer.transform = t1;
}];
[UIView addKeyframeWithRelativeStartTime:0.5f relativeDuration:0.5f animations:^{
fromViewController.view.layer.transform = t2;
}];
} completion:^(BOOL finished) {
}];
[UIView animateWithDuration:duration delay:(halfDuration - (0.3*halfDuration)) usingSpringWithDamping:0.7f initialSpringVelocity:6.0f options:UIViewAnimationOptionCurveEaseIn animations:^{
toViewController.view.frame = inView.frame;
} completion:^(BOOL finished) {
[self.transitionContext completeTransition:YES];
}];
}
Saat [self.transitionContext completeTransition:YES];
dipanggil, tiba-tiba pengontrol tampilan pertama menghilang dan layar hitam ditampilkan di bawah pengontrol tampilan kedua.
Apakah ada yang punya ide? Terima kasih.