У меня есть контроллер камеры. Я хочу подтолкнуть его. Но я хочу, чтобы он исчез, пока я его нажимаю. Как мне это сделать. Я не использую UINavigationController.Пользовательские анимации UIViewController БЕЗ UINAVIGATIONCONTROLLER
ответ
Вы «нажимаете» контроллер вида на стек навигационной панели. Но когда вы представляете контроллер вида без контроллера навигации, вы называете его «настоящим» (а не «push»). Означает, что термин «толкание» контроллера просмотра вряд ли подключен к UINavigationController
.
Таким образом, вы можете просто использовать Google для чего-то вроде «пользовательского перехода UIViewController» или чего-то подобного.
I did great success following a this great article by Teehan+Lax. Просто прочитайте его, это должно привести вас к правильному пути.
EDIT Хорошо. Я собираюсь добавить некоторую информацию, чтобы дать вам лучший ответ.
Прежде всего, вы будете создавать новый подкласс NSObject
и соответствовать UIViewControllerAnimatedTransitioning
протокола:
@interface JWTransitionAnimator <UIViewControllerAnimatedTransitioning>
+ (JWTransitionAnimator *)transitionAnimatorForPresentation;
+ (JWTransitionAnimator *)transitionAnimatorForDismissal;
@end
Затем пусть волшебство произойдет в вашей реализации:
@interface JWTransitionAnimator()
@property (atomic, assign, getter=isPresenting) BOOL presenting;
@end
@implementation JWTransitionAnimator
+ (JWTransitionAnimator *)transitionAnimatorForPresentation {
JWTransitionAnimator *animator = [[self alloc] init];
[animator setPresenting:YES];
return animator;
}
+ (JWTransitionAnimator *)transitionAnimatorForDismissal {
return [[self alloc] init];
}
// implement the protocol:
- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitioningContext {
return 0.3; // or any other duration.
}
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitioningContext {
UIViewController *fromViewController = [transitioningContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toViewController = [transitionContext UITransitionContextToViewController];
UIView *fromView = [fromViewController view];
UIView *toView = [toViewController view];
if ([self isPresenting]) {
[fromView setUserInteractionEnabled:NO];
[[transitionContext containerView] addSubview:fromView];
[[transitionContext containerView] addSubview:toView];
[toView setAlpha:0.0];
[toView setTransform:CGAffineTransformScale([fromView transform], 0.3, 0.3)];
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
[fromView setTintAdjustmentMode:UIViewTintAdjustmentModeDimmed];
[toView setAlpha:1.0];
[toView setTransform:CGAffineTransformScale([toView transform], 1.0, 1.0)];
} completion:^(BOOL finished) {
[transitionContext completeTransition:finished];
}];
}
else {
// reverse your animation here (change "fromView" for "toView" and vice-versa)
}
}
Ваш предлежащей viewController должен соответствовать протоколу UIViewControllerTransitionDelegate
. Реализовать его следующим образом:
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {
return [JWTransitionAnimator transitionAnimatorForPresentation];
}
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed {
return [JWTransitionAnimator transitionAnimatorForDismissal];
}
вы представить контроллер представления, как это:
- (IBAction)presentViewController:(id)sender {
UIViewController *yourVC = [[UIViewController alloc] init]; // however you create it
[yourVC setModalPresentationStyle:UIModalPresentationStyleCustom];
[yourVC setTransitionDelegate:self];
[self presentViewController:yourVC animated:YES completion:NULL];
}
- 1. Пользовательские анимации с UIViewController
- 2. push UIViewController без UINavigationController
- 3. Пользовательские анимации для UINavigationController толчка не оказывающий NavBar правильно
- 4. Анимация Push Segue без UINavigationController
- 5. UINavigationController изменение анимации
- 6. Раскадровка - Pop to Root UIViewController без UINavigationController?
- 7. Управление несколькими Uiviewcontroller без использования Uinavigationcontroller
- 8. Показать UINavigationController с анимацией UIViewController
- 9. UINavigationController в UIViewController сложности
- 10. ios uinavigationcontroller в uiviewcontroller
- 11. UINavigationController от UIViewController
- 12. Добавить UINavigationController внутри UIViewController
- 13. Нажатие UIViewController на UINavigationController
- 14. iPhone UINavigationController внутри UIViewController
- 15. UIViewController Контейнерные субконтроллеры анимации
- 16. Начните новый UIViewController от UINavigationController
- 17. Пользовательские переходы iOS7 с UINavigationController
- 18. Проблема анимации UINavigationController
- 19. Как я могу отключить вручную UIViewController из другого UIViewController в UINavigationController без импорта первого класса UIViewController?
- 20. Без анимации при нажатии контроллеров просмотра в UINavigationController
- 21. UINavigationController как дочерний вид UIViewController
- 22. Программным добавить UINavigationController в UIViewController
- 23. Создание UINavigationController для первого UIViewController
- 24. Добавление UINavigationController к существующему UIViewController
- 25. Проблемы с UIViewController и UINavigationController
- 26. разматывает от UINavigationController к UIViewController
- 27. Как работает UINavigationController и UIViewController?
- 28. Разница между UIViewController и UINavigationController?
- 29. UIViewAnimation, выполненный UIViewController, принадлежащим UINavigationController?
- 30. Пейзаж только UIViewController в UINavigationController