Mục tiêu của tôi là cung cấp quá trình chuyển đổi thu phóng từ người dùng từ chế độ xem tương tự như biểu tượng bàn đạp phóng to khi khởi chạy ứng dụng.Thanh điều hướng được điều chỉnh sau khi gọi completeTransition: trong chuyển đổi tùy chỉnh
Trình điều khiển chế độ xem được trình bày phóng to chính xác, nhưng thanh điều hướng có vị trí sai trong thanh trạng thái. Vị trí này được sửa sau khi gọi [transitionContext completeTransition: finished] ;. Làm thế nào tôi có thể làm cho nó chính xác từ đầu của quá trình chuyển đổi?
Đây là một ghi âm màn hình của lỗi: http://youtu.be/7LKU4lzb-uw (các trục trặc là trong lần thứ hai 6 của bản ghi)
Mã UIViewControllerAnimatedTransitioning:
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
{
UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
UIView *container = [transitionContext containerView];
CGPoint viewCenter = self.view.center;
CGSize viewSize = self.view.frame.size;
CGSize controllerSize = toViewController.view.frame.size;
CGFloat controllerFromX = viewCenter.x - (controllerSize.width/2);
CGFloat controllerFromY = viewCenter.y - (controllerSize.height/2);
CGAffineTransform transform = CGAffineTransformMakeTranslation(controllerFromX, controllerFromY);
transform = CGAffineTransformScale(transform, viewSize.width/controllerSize.width, viewSize.height/controllerSize.height);
if (self.reverse) {
[container insertSubview:toViewController.view belowSubview:fromViewController.view];
} else {
toViewController.view.transform = transform;
[container addSubview:toViewController.view];
}
[UIView animateKeyframesWithDuration:ZoomTransitioningDuration
delay:0
options:0
animations:^{
if (self.reverse) {
fromViewController.view.alpha = 0.0f;
fromViewController.view.transform = transform;
} else {
toViewController.view.transform = CGAffineTransformIdentity;
}
}
completion:^(BOOL finished) {
[transitionContext completeTransition:finished];
}];
}
Bạn không thể điều chỉnh nguồn gốc của chế độ xem tương ứng? –
Khi tôi làm điều đó, khu vực bên dưới thanh trạng thái là màu đen, không phải màu xanh lá cây (toàn bộ bộ điều khiển được dịch chuyển xuống dưới). –
Tự chụp ảnh ở đâu? Bộ điều khiển hiển thị có phải là bộ điều khiển hoạt ảnh không? – bilobatum