은, 이것에 대한 이유는 jQuery과 할 필요가 그래서 접을 헤더를 사용하고 있다는 점이다. 이 코드는 UICollectionViewCell 대신 UITableViewCell이 될 것이고 xib 파일은 다를 것입니다. 어떻게 든이 코드를 복사 - 붙여 넣기 대신 UITableViewCell에 다시 사용할 수있게 할 수 있을까요?UITableView 내부에서 UICollectionViewCell에 동일한 코드를 어떻게 사용할 수 있습니까? 나는 UICollectionView에서 동일한 셀 설정하지만, jQuery과의 내부에이 시간을 사용하고
class LoggedExerciseCell: UICollectionViewCell {
// MARK: - IBOutlets
@IBOutlet var cell: UICollectionViewCell!
@IBOutlet var loggedSetTableView: LoggedSetsTableView!
@IBOutlet weak var exerciseName: UILabel!
@IBOutlet weak var exerciseCount: UILabel!
@IBOutlet weak var icon: UIImageView!
@IBOutlet weak var resistanceType: UILabel!
@IBOutlet weak var repetitionType: UILabel!
// MARK: - Object Lifecycle
override init(frame: CGRect) {
super.init(frame: frame)
commonInit()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
commonInit()
}
// MARK: - Configure Cell
func configure(_ exercise: LoggedExerciseViewModelView) {
self.exerciseName.text = exercise.exerciseName
self.icon.image = UIImage(named: exercise.icon)
self.resistanceType.text = exercise.resistanceType
self.repetitionType.text = exercise.repetitionType
self.loggedSetTableView.loggedExerciseViewModel = exercise
}
}
// MARK: - CommonInit
private extension LoggedExerciseCell {
func commonInit() {
Bundle.main.loadNibNamed("LoggedExerciseCell", owner: self, options: nil)
cell.frame = self.bounds
addSubview(cell)
configureViews()
}
}
// MARK: - ConfigureViews
private extension LoggedExerciseCell {
func configureViews() {
configureIconImageView()
}
func configureIconImageView() {
icon.setCircularImageViewWithBorder(borderWidth: 1.2, withBorderColor: UIColor.darkBlue().cgColor)
}
}
셀 클래스이기 때문에 당신은 유사한 코드 있지만 같은 코드를 사용할 수 있습니다 동일하지 않으며, 대의원은 다르다. – Raptor
은 하나 개의 링크가 매우 유용 https://ashfurrow.com/blog/putting-a-uicollectionview-in-a-uitableviewcell-in-swift/ –
난 당신이뿐만 아니라 UICollectionView에서 헤더를 상자를 확장 할 수 있습니다 생각하십시오. 사용해보기 : https://stackoverflow.com/questions/32046292/uicollectionview-header-change-height-in-ibaction – danieltmbr