是否可以根据页面控件中的数组计数创建模板并添加一定数量的视图控制器?

时间:2016-02-26 04:34:26

标签: ios swift uipageviewcontroller

我所做的是将容器视图放在具有许多对象的视图控制器中,并在容器视图中嵌入视图控制器。然后我有了cardview视图控制器,这是我在pageviewcontroller中为每个页面提供图像,标签等的地方。我还实例化了页面视图控制器。它们的大小与容器大小相同。它一直在崩溃这种方法。要查看所有代码,请参阅https://www.veasoftware.com/posts/uipageviewcontroller-in-swift-xcode-62-ios-82-tutorial

database {
  dataSourceClass = "org.postgresql.ds.PGSimpleDataSource"
  properties = {
    databaseName = "dbname"
    user = "postgres"
    password = "password"
  }
  numThreads = 10

}

1 个答案:

答案 0 :(得分:0)

您的viewController可能不属于cardview类。试试这段代码,看看你是否得到了日志和viewController的类型。

guard let vc = viewController as? cardview else {
  print("viewController is not of type cardview. Its of type \(viewController.dynamicType)")
  return nil
}

var index = vc.pageIndex as Int