我試圖將圖像放入我的UITableView
。該表是使用自定義子類單元設置的。在子類我有網點:在UITableView中加載圖像時出現問題
@IBOutlet var titleLabel: UILabel!
`@IBOutlet var pillarIcon: UIImageView!`
在超我創建了兩者NSMutableArray
:
var objects: NSMutableArray! = NSMutableArray()
var imageObjects: NSMutableArray! = NSMutableArray()
我放置viewDidLoad
方法中,每個陣列具有4內的東西到陣列項目。
所以,當我撥打的項目:
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.objects.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = self.tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! TableViewCell
cell.titleLabel.text = self.objects.objectAtIndex(indexPath.row) as? String
cell.pillarIcon.image = self.imageObjects.objectAtIndex(indexPath.row) as? UIImage
return cell
}
的cell.titleLabel.text
項目上來,但在cell.pillarIcon.image
圖像不進來表顯示出來。
我一直在爲此工作了幾個小時,現在正在圈子裏感受。此外,圖像文件已被加載到主文件,所以這不是問題。
在此先感謝。
您是否嘗試過更具體的數組類型?嘗試: var objects = [UIImage]() var imageObjects = [String]() – MQLN
如何在'imageObjects'屬性中加載圖像值? – whyceewhite
@whyceewhite我正在加載像這樣的圖像:'self.imageObjects.addObject(「book.jpg」)' 'self.imageObjects.addObject(「bookmark.png」)' – Rico