下面是我的代码:
var arrCategory:[NSString] =
["Australia","Austria","Belgium","Brazil","Cameroon","Canada","Chile","China","Denmark","Argentina"]
上面数组中给出的字符串是图像的名称。
最佳答案
将代码替换为:
cell.imageView?.image = UIImage(named: "\(self.arrCategory[indexPath.row]).png")
cell.LblName.text = "\(self.arrCategory[indexPath.row])"
关于objective-c - 如何将图像设置到 NSCollectionView 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45235145/