0

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

ritvik1512
  • 303
  • 1
  • 3
  • 10
  • 1
    `transitionDuration` is outside the class calling it, that's why " TransitionManager does not have a member named transitionDuration" happens. Put `transitionDuration` *inside* the `TransitionManager` class to fix this error. – Eric Aya Apr 20 '15 at 12:00
  • 1
    Cool! I'm writing a proper answer so it could help other users. – Eric Aya Apr 20 '15 at 12:05

1 Answers1

2

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.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253