ritvik1512
ritvik1512

Reputation: 331

Error in conforming with UIViewControllerAnimatedTransitioning protocol while trying Custom Animations

I've been following a tutorial online about creating custom animations. So for making the custom animations, I created a class name Transition Manager of type NSObject. I'm facing two problems,

1) So when further defining the class as,

class TransitionManager: NSObject, UIViewControllerAnimatedTransitioning, 
UIViewControllerTransitioningDelegate
{
    //Further Code
}

I get a compile time error,

Type 'TransitionManager' does not conform to protocol 
'UIViewControllerAnimatedTransitioning'

and

Protocol requires function 'transitionDuration' with type 
'(UIViewControllerContextTransitioning) -> NSTimeInterval'

Here is the 'transitionDuration' function:

// return how many seconds the transition animation will take
func transitionDuration(transitionContext: UIViewControllerContextTransitioning) -> NSTimeInterval
{
    return 0.5
}

2) Another compile time error pops up, at the following line:

  // get the duration of the animation

    let duration = self.transitionDuration(transitionContext)

Error:

  'TransitionManager' does not have a member named 'transitionDuration'

Here is the complete TransitionManager.swift: http://pastebin.com/LkLym5Ci

Upvotes: 0

Views: 495

Answers (1)

Eric Aya
Eric Aya

Reputation: 70098

Your transitionDuration method is currently outside the class, as shown in the PasteBin.

That's why you get an error message saying that transitionDuration is not a member of the class.

If you put the transitionDuration method inside the TransitionManager class the error will disappear.

Upvotes: 2

Related Questions