我的viewController
containerView
pageView
。一旦我从pageView中滑动视图,我想在viewController中调用一个函数,我已尝试使用下面的代码,但它正在调用buttonMaskColor
请问哪里会是我的问题?
class PlaceMenuDetailsViewController: UIViewController, PageViewSliderDelegate {
override func viewDidLoad() {
super.viewDidLoad()
detailsButton.pageDelegation = self
}
func buttonMaskColor(){
println("delegate work")
}
}
class DetailPageViewController: UIPageViewController, UIPageViewControllerDelegate, UIPageViewControllerDataSource {
weak var pageDelegation:PageViewSliderDelegate?
func pageViewController(pageViewController: UIPageViewController, viewControllerAfterViewController viewController: UIViewController) -> UIViewController? {
pageDelegation?.buttonMaskColor()
var page = (viewController as! PageDelegate).pageNumber + 1
return viewControllerForPage(page)
}
答案 0 :(得分:2)
在给出embed segue的标识符后,你应该在mainView的prepareForSegue函数中将self赋给pageDelegation,如下所示:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "embedSegueIdentifier" {
let distinationVC = segue.destinationViewController as? DetailPageViewController
distinationVC?.pageDelegation = self
}
}