Поддържайте видим първия View Controller на персонализирания Segue

Имам три контролера за изглед, които са подредени като snapchat. Основният е вграден в UINavigationController и е в средата с контролер за изглед отляво и един отдясно. Преходът работи добре, ляво/дясна анимация. Но в snapchat, когато превключите на контролер до камерата или обратното, камерата ще остане видима (не е оцветена в черно) в персонализирания преход. С МОЯ, ако натисна втория контролер за изглед в стека, първият контролер за изглед изглежда черен, тъй като анимацията започва, когато искам да остане напълно видима. Предполагам, че трябва да променя нещо в персонализирания си режим.

 @implementation toTheRight

- (void) perform{
UIViewController *sourceViewController = (UIViewController *)self.sourceViewController;
UIViewController *destinationViewController = (UIViewController *)self.destinationViewController;

CATransition *transition = [CATransition animation];
transition.duration = .5;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;

[sourceViewController.navigationController.view.layer addAnimation:transition forKey:kCATransition];
[sourceViewController.navigationController pushViewController:destinationViewController animated:NO];
}

person Peter    schedule 19.05.2015    source източник


Отговори (1)


Взети от тези два проекта, след което модифицирани CustomSegue и CustomUnwindSegue като пример. https://github.com/soleares/SOLPresentingFun https://github.com/Phillipus/CustomSegue

CustomSegue.m

#import "CustomSegue.h"
#import "SOLSlideTransitionAnimator.h"

@interface CustomSegue()<UIViewControllerTransitioningDelegate>
@property (nonatomic,strong) SOLSlideTransitionAnimator* animator;
@end

@implementation CustomSegue

- (void)perform {
    UIViewController *sourceViewController = self.sourceViewController;
    UIViewController *destinationViewController = self.destinationViewController;

    destinationViewController.transitioningDelegate = self;
    destinationViewController.modalPresentationStyle = UIModalPresentationCustom;

    [sourceViewController presentViewController:destinationViewController animated:YES completion:nil];
}

/*
 Called when presenting a view controller that has a transitioningDelegate
 */
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented
                                                                  presentingController:(UIViewController *)presenting
                                                                      sourceController:(UIViewController *)source
{
    self.animator.appearing = YES;
    return self.animator;
}

-(SOLSlideTransitionAnimator*) animator
{
    if(!_animator)
    {
        _animator = [[SOLSlideTransitionAnimator alloc] init];
        _animator.appearing = NO;
        _animator.duration = 0.35;
        _animator.edge = SOLEdgeRight;
    }
    return _animator;
}

@end

CustomUnwindSegue.m

@interface CustomUnwindSegue()<UIViewControllerTransitioningDelegate>
@property (nonatomic,strong) SOLSlideTransitionAnimator* animator;
@end



#import "CustomUnwindSegue.h"
#import "SOLSlideTransitionAnimator.h"

@implementation CustomUnwindSegue

- (void)perform {
    UIViewController *sourceViewController = self.sourceViewController;

    sourceViewController.transitioningDelegate = self;
    sourceViewController.modalPresentationStyle = UIModalPresentationCustom;

    [sourceViewController dismissViewControllerAnimated:YES completion:nil];
}

-(SOLSlideTransitionAnimator*) animator
{
    if(!_animator)
    {
        _animator = [[SOLSlideTransitionAnimator alloc] init];
        _animator.appearing = NO;
        _animator.duration = 0.35;
        _animator.edge = SOLEdgeRight;
    }
    return _animator;
}

/*
 Called when dismissing a view controller that has a transitioningDelegate
 */
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed
{
    self.animator.appearing = NO;
    return self.animator;
}

@end
person user1036272    schedule 16.07.2015