2016-10-08 7 views
-1

다음 사용자 지정보기 전환이이 tutorial 다음에 만들려고합니다. 여기에 내 코드사용자 지정보기 컨트롤러 전환 xcode8

class ItemsTableViewController: UITableViewController, UIViewControllerTransitioningDelegate { 

let customPresentAnimationController = CustomPresentAnimationController() 

// viewDidLoad and TableView methods 

override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 
    if segue.identifier == "showAction" { 
     let toViewController = segue.destination as UIViewController 
     toViewController.transitioningDelegate = self 
     toViewController.modalPresentationStyle = .custom 
    } 
} 

func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? { 
    return customPresentAnimationController 
} 

}

및 사용자 정의 전환이 작동하지 않습니다 그러나 CustomPresentAnimationController

class CustomPresentAnimationController: NSObject, UIViewControllerAnimatedTransitioning { 

func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { 
    return 5 
} 

func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { 

    let fromViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)! 
    let toViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)! 
    let finalFrameForVC = transitionContext.finalFrame(for: toViewController) 
    let containerView = transitionContext.containerView 
    let bounds = UIScreen.main.bounds 
    toViewController.view.frame = finalFrameForVC.offsetBy(dx: 0, dy: bounds.size.height) 
    containerView.addSubview(toViewController.view) 

    UIView.animate(withDuration: transitionDuration(using: transitionContext), delay: 0.0, usingSpringWithDamping: 0.5, initialSpringVelocity: 0.0, options: .curveLinear, animations: { 
     fromViewController.view.alpha = 0.5 
     toViewController.view.frame = finalFrameForVC 
     }, completion: { 
      finished in 
      transitionContext.completeTransition(true) 
      fromViewController.view.alpha = 1.0 
    }) 
} 

}

입니다. animationControllerForPresentedController 메소드가 호출되지 않는 것이 문제입니다. 어떻게 해결할 수 있습니까? 신속한 3에서

답변

0

func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? { 
return customPresentAnimationController 
} 

func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? { 
    return customPresentAnimationController 
} 
로 대체 된 방법