Prashanth
Prashanth

Reputation: 548

Swift 2: Type of expression is ambiguous without more context

class Example: NSObject, UIViewControllerAnimatedTransitioning, UIViewControllerTransitioningDelegate {

var aView : UIView!

UIView.animateWithDuration(duration, delay: 0.0, usingSpringWithDamping: 0.8, initialSpringVelocity: 0.8, options: nil, animations: {

       self.aView.transform = CGAffineTransformIdentity //This line is throwing the error mentioned in the Title


            }, completion: { finished in
                transitionContext.completeTransition(true)
      })


}

This was working in earlier version of Swift but failing in version 2 not sure why

Upvotes: 3

Views: 4001

Answers (1)

Antoine
Antoine

Reputation: 1149

You just have to change

UIView.animateWithDuration(duration,
  delay: 0.0,
  usingSpringWithDamping: 0.8,
  initialSpringVelocity: 0.8,
  options: nil,
  animations: {

with:

UIView.animateWithDuration(duration,
  delay: 0.0,
  usingSpringWithDamping: 0.8,
  initialSpringVelocity: 0.8,
  options: [],
  animations: {

There is just the "options" to change.

Upvotes: 5

Related Questions