import UIKit
class ViewController: UIViewController,UICollectionViewDelegate,UICollectionViewDataSource {
var shoppingapp:[String] = ["cher","sale Small","shoes"]
override func viewDidLoad() {
super.viewDidLoad()
}
//this function is not working in my xcode 13 not calle this function
# func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
# return shoppingapp.count
# }
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! MyCollectionCell
cell.shoppinfappimage.image = UIImage(named: shoppingapp[indexPath.row] + ".jpeg")
cell.shoppinfappimage.layer.cornerRadius=50.0
return cell
}
}
我不知道还有哪种方法是我正在学习和实践的iOS应用程序开发****
1条答案
按热度按时间8gsdolmq1#
首先,请删除代码中的#,将其划分为ViewController扩展。
但是当我看到你的代码时,我认为你没有声明delegate和DataSource。
在viewDidLoad中编写上面的代码。所以我也不能做太多。
如果不管用,就这样试试。
我希望写作对我有帮助。