1

Я пытаюсь интерактивно уволить UINavigationController с на UIViewController на своем стекеуволить UINavigationController интерактивными

я. Я представляю следующее:

UIViewController *vc = [UIViewController new]; 
UINavigationController *nav = [[UINavigationController alloc] initWithRoot:vc]; 
[self presentViewController:nav animated:YES completion:nil]; 

ii .. В моем контроллере ViewController я установлен в файле .h. В .m файле я установил self.transitioningDelegate.self Я также пробовал self.navigationController.transitioningDelegate = self

iii. Наконец, я применяю методы делегатов:

#pragma mark - ViewControllerTransitioning Delegate Methods 
- (id<UIViewControllerAnimatedTransitioning>) 
animationControllerForPresentedController:(UIViewController *)presented 
presentingController:(UIViewController *)presenting 
sourceController:(UIViewController *)source { 
    NSLog(@"\n\nTRANSIT 1\n\n"); 
    // allow the interaction controller to wire-up its gesture recognisers 
    [_interactionController wireToViewController:presented 
            forOperation:CEInteractionOperationDismiss]; 
    _animationController.reverse = NO; 
    return _animationController; 
} 

- (id<UIViewControllerAnimatedTransitioning>) 
animationControllerForDismissedController:(UIViewController *)dismissed { 
    NSLog(@"\n\nTRANSIT 2\n\n"); 
    _animationController.reverse = YES; 
    return _animationController; 
} 

- (id<UIViewControllerInteractiveTransitioning>) 
interactionControllerForDismissal: 
(id<UIViewControllerAnimatedTransitioning>)animator { 
    NSLog(@"\n\nTRANSIT 3\n\n"); 
    // provide the interaction controller, if an interactive transition is in progress 
    return _interactionController.interactionInProgress 
    ? _interactionController : nil; 
} 

iv. К сожалению, интерактивная часть никогда не выполняется. Когда я вручную нажимаю кнопку, которая вызывает [self dismissViewControllerAnimated:YES completion:nil];

Печатаются как транзит 2, так и транзит 3, но транзит 1 никогда не доходит. Есть ли у кого-нибудь предложения, что это может быть? Благодаря!

+0

Я не уверен, но вы можете попробовать '[self.navigationController popViewControllerAnimated: YES];' вместо '[self rejectViewControllerAnimated: YES complete: nil];'. Я думаю что. –

+0

, к сожалению, не будет работать – trdavidson

ответ

0

Да! Наконец решил это. Проблема заключается в том, что в момент представления нового UIViewController с помощью: UINavigationController *n = [[UINavigationController alloc] initWithRoot:yourVC] [self presentViewController:n animated:YES completion:nil];

ток представления ViewController будет выглядеть в n методов transitioningDelegate, а именно:

- (id<UIViewControllerAnimatedTransitioning>) 
animationControllerForPresentedController:(UIViewController *)presented 
presentingController:(UIViewController *)presenting 
sourceController:(UIViewController *)source { 
    NSLog(@"\n\nTRANSIT 1\n\n"); 
    // allow the interaction controller to wire-up its gesture recognisers 
    [_interactionController wireToViewController:presented 
            forOperation:CEInteractionOperationDismiss]; 
    _animationController.reverse = NO; 
    return _animationController; 
} 

, который используется для проволоки жест распознаватель в interactionController в не называется. Поэтому, чтобы обойти эту проблему, мы должны вызвать следующее, который будет представлен viewDidLoad в ViewController в:

[_interactionController wireToViewController:self forOperation:CEInteractionOperationDismiss]; 

Таким образом ViewController будет подключен и хорошо идти. Единственная непонятная проблема заключается в том, что перевод, кажется, увеличивается на 5 раз - любые предложения относительно того, почему это может быть оценено!