iOS: 在 Swift3 中,在 UICollectionViewLayout 部分,如何访问主要的 CollectionView 属性?
iOS: in Swift3, in the UICollectionViewLayout section, how can I access to the main CollectionView properties?
当我在 UICollectionViewLayout 部分时,我可以看到我的主 class 中的主 collectionView 中有值。问题是我不知道如何访问主要 class.
的属性
时间表示例 属性:
主体声明class:
import UIKit
@objc class PlanningViewController: UIViewController {
let oneDay:TimeInterval = 24*60*60
var typePlanning: String = "" //Type planning only in RENAULT_KADJAR
//Size Array
var timeTable : [[Int]] = []//property I want to access
var uniqueValues : Array<Int> = []
...
在 UICollectionViewLayout 中,我在“delegate”的调试屏幕中看到值:
我准确地说我使用了两个不同的 classes 和故事板。
非常感谢。
您可以从布局中的任何位置调用 self.collectionView class 并且它将 return 布局所属的 UICollectionView 对象。
在你的 UICollectionViewLayout
let planningView = self.delegate as! PlanningViewController
var timeTable = planningView.timeTable
您现在可以访问您的数据
当我在 UICollectionViewLayout 部分时,我可以看到我的主 class 中的主 collectionView 中有值。问题是我不知道如何访问主要 class.
的属性时间表示例 属性:
主体声明class:
import UIKit
@objc class PlanningViewController: UIViewController {
let oneDay:TimeInterval = 24*60*60
var typePlanning: String = "" //Type planning only in RENAULT_KADJAR
//Size Array
var timeTable : [[Int]] = []//property I want to access
var uniqueValues : Array<Int> = []
...
在 UICollectionViewLayout 中,我在“delegate”的调试屏幕中看到值:
我准确地说我使用了两个不同的 classes 和故事板。
非常感谢。
您可以从布局中的任何位置调用 self.collectionView class 并且它将 return 布局所属的 UICollectionView 对象。
在你的 UICollectionViewLayout
let planningView = self.delegate as! PlanningViewController
var timeTable = planningView.timeTable
您现在可以访问您的数据