我正在使用BBWalkthrough(https://github.com/ariok/BWWalkthrough),我想直接从presentViewController
转换到BWWalkthroughViewController的UIScrollView中的特定页面。
我该怎么做?注意我没有使用segues,因为viewController在不同的故事板中。
如果我对BBWalkthroughViewController实例presentViewController()
的子VC进行了walk
,那么它就可以正常显示但是你无法从该视图滚动(即你在视图中但没有滚动功能它与其他视图没有任何联系。)
func instantiateControllers(){
// Get view controllers and build the walkthrough
let stb = UIStoryboard(name: "Walkthrough", bundle: nil)
let walkthrough = stb.instantiateViewControllerWithIdentifier("walk") as! BWWalkthroughViewController
let page_A = stb.instantiateViewControllerWithIdentifier("walkA") as! UIViewController
let page_B = stb.instantiateViewControllerWithIdentifier("walkB") as! UIViewController
let page_C = stb.instantiateViewControllerWithIdentifier("walkC")as! UIViewController
let page_D = stb.instantiateViewControllerWithIdentifier("walkD")as! UIViewController
let page_E = stb.instantiateViewControllerWithIdentifier("walkE")as! UIViewController
let page_outro = stb.instantiateViewControllerWithIdentifier("walkOUT")as! UIViewController
// Attach the pages to the master
walkthrough.delegate = self
walkthrough.addViewController(page_A)
walkthrough.addViewController(page_B)
walkthrough.addViewController(page_C)
walkthrough.addViewController(page_D)
walkthrough.addViewController(page_E)
walkthrough.addViewController(page_outro)
self.presentViewController(walkthrough, animated: true, completion: nil)
}
答案 0 :(得分:3)
我只需要调用@IBAction func nextPage()
walkthrough
方法所需的次数。它相当于模拟用动画完成的用户页面点击,这可能是一个错误或一个功能。
或者只是破解代码的来源 - 这是开源的重点。 :-)只需将gotoPage()
函数设置为非私有,并从上面的代码中调用一次。没有充分的理由让设计将该功能变为私有。
在任何一种情况下,我都认为你必须这样做,作为完成处理程序的一部分。
示例:
// Assuming you've removed 'private' from the gotoPage() function
self.presentViewController(walkthrough, animated: true) { walkthrough.gotoPage(3) }
或:
self.presentViewController(walkthrough, animated: true) {
for _ in 0..<3 {
walkthrough.nextPage()
}
}