public func viewController() -> UIViewController? { var responder = self.next; repeat { if (responder?.isKind(of: UIViewController.classForCoder()))! { return responder as? UIViewController } responder = responder?.next } while((responder) != nil) return nil; }原文链接:/swift/322637.html