2016-01-29 84 views
-1
import Foundation 
import UIKit 

enum TransitionType { 
    case Presenting, Dismissing 
} 

class AnimationController: NSObject, UIViewControllerAnimatedTransitioning { 
    var duration: NSTimeInterval 
    var isPresenting: Bool 
    var originFrame: CGRect 

    init(withDuration duration: NSTimeInterval, forTransitionType type: TransitionType, originFrame: CGRect) { 
     self.duration = duration 
     self.isPresenting = type == .Presenting 
     self.originFrame = originFrame 

     super.init() 
    } 

    func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval { 
     return self.duration 
    } 
} 

代碼改編自下面的教程:類型 'AnimationController' 不符合協議 'UIViewControllerAnimatedTransitioning'

+0

始終是一個很好的提示命令+點擊委託內部,看看該協議強制哪些功能,沒有標記爲「可選」,看看有什麼缺失 –

回答

1

這是錯誤的話。該代碼尚未完全採用UIViewControllerAnimatedTransitioning協議。您需要實施public func animateTransition(transitionContext: UIViewControllerContextTransitioning),這發生在您鏈接到的文章的下一代碼塊中。

相關問題