我正在使用UIPageMenuController。当我点击按钮时,我必须转到3页。
我试图调用will willMoveToPage委托方法,得到错误
willMoveToPage:index:]:发送到实例的选择器无法识别
以下是我的代码:
let storyBoard = UIStoryboard.init(name: "Main", bundle: nil)
let yourVC = storyBoard.instantiateViewController(withIdentifier: "ProfileConnectionsController") as! ProfileConnectionsController
pageMenu?.delegate?.willMoveToPage!(yourVC, index: 2)
最佳答案
错误为willMoveToPage:index:]:无法识别的选择器发送到实例您没有实现委托方法
步骤1
确保在类中实现一次委托
class ViewController:UIViewController,CAPSPageMenuDelegate
一旦你确认了代表
pageMenu.delegate=self
步骤2
之后,您将能够在父视图控制器内设置以下委托方法
确保调用方法一次
func willMoveToPage(controller: UIViewController, index: Int) {
if let getSubview=controller as! ProfileConnectionsController
{
getSubview.pageNumber=index
}
}