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