我試圖將圖像文字添加到數組,並按照索引顯示它們。如何將圖像文字添加到數組並顯示它們?
這裏是我的代碼:
var images = [#imageLiteral(resourceName: "male-circle-128"),#imageLiteral(resourceName: "add_to_favourite-128"),#imageLiteral(resourceName: "28468-200"),#imageLiteral(resourceName: "progress_circular"),#imageLiteral(resourceName: "logout-1-128")]
和展示這樣
cell!.imageView?.image = UIImage.init(cgImage: images[indexPath.row] as! CGImage)
了EXC_BAD_INSTRUCTION!什麼是做這個
不要理解爲什麼你會因數組聲明而崩潰,因爲它對我來說是完美的。 –
@EricAya no UIImage only –
當我將這些元素添加到數組時,會崩潰。 –