我在从子$ dpkg -l | grep linux-headers-
ii linux-headers-4.15.0-23
ii linux-headers-4.15.0-43
ii linux-headers-4.15.0-43-generic
ii linux-headers-generic
属性访问父属性时遇到问题。
父级是模态的UICollectionViewController
,添加了ChildViewController
的代码看起来像
UICollectionViewController
和let assetPickerController = AssetGridViewController(collectionViewLayout: GridFlowLayout())
addChildViewController(assetPickerController)
let childView = assetPickerController.view!
assetPickerController.par = self
assetPickerController.nav = self.navigationController
assetPickerController.didMove(toParentViewController: self)
具有以下代码,显示为nil
AssetGridViewController
但是它可以获取let svc = self as! UIViewController
let parentSize = svc.parent!.view.frame.size
print(parentSize)
属性(我自己创建)。我不太确定为什么会这样,这是一个par
问题,还是因为它是模态下的子代而发生了?
答案 0 :(得分:0)
将父级大小作为类的属性传递。
添加属性
var parentSize
放入assetPickerController,这样您就可以
assetPickerController.parentSize = self.view.frame.size //Before didMove
assetPickerController.didMove(toParentViewController: self)