MG
Size: a a a
MG
А
MG
MG
А
MG
А
class QuestionViewController: UIViewController {
var array: [String] = []
@IBOutlet weak var collectionView: UICollectionView!
override func viewDidLoad() {
setapCollectionView()
}
private func setapCollectionView() {
collectionView.dataSource = self
collectionView.delegate = self
collectionView.register(UINib(nibName:
"AnswersCollectionViewCell
", bundle: nil), forCellWithReuseIdentifier:
"AnswersCollectionViewCell
")
collectionView.isUserInteractionEnabled = true
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return array.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "AnswersCollectionViewCell", for: indexPath) as! AnswersCollectionViewCell
cell.labelText.text = array[indexPath.item].text
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
print(#function)
}
}
MG
class QuestionViewController: UIViewController {
var array: [String] = []
@IBOutlet weak var collectionView: UICollectionView!
override func viewDidLoad() {
setapCollectionView()
}
private func setapCollectionView() {
collectionView.dataSource = self
collectionView.delegate = self
collectionView.register(UINib(nibName:
"AnswersCollectionViewCell
", bundle: nil), forCellWithReuseIdentifier:
"AnswersCollectionViewCell
")
collectionView.isUserInteractionEnabled = true
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return array.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "AnswersCollectionViewCell", for: indexPath) as! AnswersCollectionViewCell
cell.labelText.text = array[indexPath.item].text
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
print(#function)
}
}
GA
MG
MG
А
MG
a