gpt4 book ai didi

ios - 使用 presentViewController 转到 BWWalkthroughViewController 中的特定 View

转载 作者:搜寻专家 更新时间:2023-11-01 06:44:25 24 4
gpt4 key购买 nike

我正在使用 BBWalkthrough ( https://github.com/ariok/BWWalkthrough ),我想直接从 presentViewController 转换转到 BWWalkthroughViewController 的 UIScrollView 中的特定页面。

我该怎么做?请注意,我没有使用 segues,因为 viewController 在不同的 Storyboard中。

如果我对 BBWalkthroughViewController 实例 walk 的子 VC 执行 presentViewController() 然后它呈现正常但你不能滚动离开那个 View (即你在 View 但没有滚动功能,因为它与其他 View 没有任何链接)。

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)
}

最佳答案

我只是调用 walkthrough@IBAction func nextPage() 方法所需的次数。它相当于模拟用户页面点击完成动画,这是一个错误或一个功能。

要么那样,要么只是破解代码源——这就是开源的意义所在。 :-) 只需将 gotoPage() 函数设置为非私有(private)函数,然后从上面的代码中调用它一次。设计使该功能私有(private)化是没有充分理由的。

无论哪种情况,我相信您都必须作为完成处理程序的一部分这样做。

例子:

// 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()
}
}

关于ios - 使用 presentViewController 转到 BWWalkthroughViewController 中的特定 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31975022/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com