dimanche 30 novembre 2014

Custom transition between UIControllers does not work

I have object that manage custom transition:



@interface NavigationManager : NSObject <UIViewControllerAnimatedTransitioning>

-(NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext;
-(void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext;

@property (nonatomic, assign) NSTimeInterval presentationDuration;
@property (nonatomic, assign) NSTimeInterval dismissalDuration;
@property (nonatomic, assign) BOOL isPresenting;


@end

@interface NavigationManager()

@property (nonatomic, strong) id<UIViewControllerContextTransitioning> transitionContext;

@end

@implementation NavigationManager

@synthesize presentationDuration, dismissalDuration, isPresenting;

-(id)init{
self = [super init];

if(self){

self.presentationDuration = 1.0;
self.dismissalDuration = 0.5;
}

return self;
}

-(NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext{

return self.isPresenting ? self.presentationDuration : self.dismissalDuration;
}

-(void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext{


self.transitionContext = transitionContext;
if(self.isPresenting){
[self executePresentation:transitionContext];
}
else{

[self executeDismiss:transitionContext];
}

}

...


@end


And in class that should process implement transitions:

@interface ViewController : UIViewController <UIViewControllerTransitioningDelegate>

@property (nonatomic, strong) NavigationManager navigationManager;

..

@end

@implementation

...


//Here I`m doing navigation to new UIViewController



- (void)navigateToNewScreen
{
DetailedNewsController *secVC = [[DetailedNewsController alloc] init];
secVC.fullDescription = fullDescription;
secVC.headerImage = a.imageView.image;
self.transitioningDelegate = self;
[self.navigationController pushViewController:secVC animated:YES];
}

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented
presentingController:(UIViewController *)presenting
sourceController:(UIViewController *)source
{
self.animationController.isPresenting = YES;
return self.animationController;
}

- (id <UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed
{
self.animationController.isPresenting = NO;
return self.animationManager;
}

@end


Default animation of transitioning is performed. Also navigation controller bar is not displayed after navigation.




Aucun commentaire:

Enregistrer un commentaire