正在使用https://github.com/xmartlabs/XLPagerTabStrip#how-to-change-the-visible-child-view-controller-programmatically在我的应用程序中...
点击一个 child 的按钮后,我想移动到另一个 child ..我尝试过:
@IBAction func morenewsbtn(_ sender: Any) {
print("clicked")
let mainpage = HomeViewController()
mainpage.moveToViewController(at: 1, animated: true)
}
但这不会移动到另一个 child ..在viewdidappear中尝试了这个并且它工作正常..但是如何在按钮点击中使用它?
最佳答案
因为这个
let mainpage = HomeViewController() // problem is here
mainpage.moveToViewController(at: 1, animated: true)
是一个新的 VC,您需要根据现有的 VC 来制作它,您可以设置对 home 的引用,或者简单地使用它
let home = self.parent as! HomeViewController
parent.moveToViewController(at: 1)
关于ios - 单击按钮导航到另一个子项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51495106/