Tôi đang thực hiện các chuyển đổi tùy chỉnh và loại bỏ tùy chỉnh và có một số vấn đề với quá trình chuyển đổi. Những gì tôi muốn làm là lặp lại hình ảnh động sâu sắc tuyệt vời này trong iOS 7 (khi chúng tôi mở/đóng một số ứng dụng). Tôi có bộ điều khiển thứ nhất và thứ hai. Tất cả các hình động đều nằm trong bộ điều khiển Đầu tiên (nó hỗ trợ UIViewControllerTransitioningDelegate và UIViewControllerAnimatedTransitioning). Vì vậy, tôi chỉ kiểm tra: nếu nó được trình bày - Tôi đang làm một hình ảnh động (mở rộng xem đầu tiên và thứ hai), nếu nó được loại bỏ - Tôi đang làm một hình ảnh động khác (mở rộng xuống lần đầu tiên và thứ hai). Hoạt ảnh hiện tại hoạt động tốt, sự cố xảy ra khi loại bỏ hoạt ảnh. Trong một số lý do khi tôi giảm kích thước bộ điều khiển thứ hai của tôi (nó là UINavigationController), tôi thấy nền đen phía sau nó (và nó sai, bởi vì tôi muốn nhìn thấy bộ điều khiển đầu tiên của tôi trong khi nó giảm tỷ lệ xuống). Đây là mã của tôi từ First Controllerios 7 tùy chỉnh hiện tại và loại bỏ quá trình chuyển đổi
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext {
UIView *transitionView = [transitionContext containerView];
id toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
id fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
BOOL isPresenting;
isPresenting = [toViewController isKindOfClass:[UINavigationController class]];
UINavigationController *navigator = isPresenting ? toViewController : fromViewController;
if (isPresenting) {
[transitionView addSubview:navigator.view];
navigator.view.transform = CGAffineTransformMakeScale(0.1, 0.1);
navigator.view.alpha = 0;
}
navigator.view.center = self.startButton.center;
void(^AnimationBlock)(void) =^{
if (isPresenting) {
navigator.view.transform = CGAffineTransformMakeScale(1, 1);
self.view.transform = CGAffineTransformMakeScale(4, 4);
navigator.view.alpha = 1;
self.startButton.alpha = 0;
} else {
navigator.view.transform = CGAffineTransformMakeScale(0.1, 0.1);
self.view.transform = CGAffineTransformMakeScale(1, 1);
navigator.view.alpha = 0;
self.startButton.alpha = 1;
}
};
[UIView animateWithDuration:1
delay:0.0f
usingSpringWithDamping:50.0
initialSpringVelocity:4
options:UIViewAnimationOptionLayoutSubviews
animations:^{
AnimationBlock();
} completion:^(BOOL finished) {
[transitionContext completeTransition:YES];
if (!isPresenting) {
[navigator.view removeFromSuperview];
}
}];
}
- (void)completeTransitionInContext:(id<UIViewControllerContextTransitioning>)transitionContext{
[transitionContext completeTransition:YES];
}
- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext{
return 1;
}
- (id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {
return self;
}
- (id <UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed {
return self;
}
Hãy cho tôi biết nếu tôi nên cung cấp thêm một số mã hoặc màn hình. Cảm ơn bạn trước!
API iOS 7 vẫn còn trong NDA, cho đến khi tính khả dụng công khai (18 bộ) – Vinzzz
Tôi gặp sự cố tương tự và API iOS7 không thuộc NDA nữa ... Bạn có thể giải thích cách giải quyết không? Cảm ơn! – veducm
Vẫn không biết câu trả lời: ( –