Manipulate IB Outlets in awakeFromNib for UICollectionViewCell even if not using custom XIB?

ぃ、小莉子 提交于 2019-12-12 00:35:18

问题


The code below is used to manipulate and configure IB Outlets of a subclassed UICollectionViewCell.

The IB outlets in the class, however, are not yet connected at this stage.

Other SO posts like this one suggest using awakeFromNib to manipulate the IB outlets, but in all the answers, the problem deals with a custom XIB.

However, this subclass doesn't use a custom XIB.

Is it still right to use awakeFromNib to configure the IB outlets even if no custom XIB is used?

override init(frame: CGRect) {
    super.init(frame: frame)

    doInit(frame)
}


required init?(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)

    doInit(frame)
}

private func doInit(frame: CGRect) {
}

来源:https://stackoverflow.com/questions/36673624/manipulate-ib-outlets-in-awakefromnib-for-uicollectionviewcell-even-if-not-using

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!