Ich habe Tabellenansicht, in denen ich 3 Zelle zeige, und hängt von der Sammlungsansicht Zelle, die wie Paging funktioniert. Wenn ich also auf Tabellenansicht Zelle das Bild bekommen von dispatch_async(dispatch_get_global_queue...)
einige Zeit bekam ich denSwift: Schwerwiegender Fehler: unerwartet gefunden Null beim Entpacken ein Optionaler Wert In dispatch_async dispatch_get_global_queue
fatal error: unexpectedly found nil while unwrapping an Optional value
meinen Code:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = self.videoTableView .dequeueReusableCellWithIdentifier("customTableViewCell") as! CustomTableViewCell
let videoDataObj:VideoData = subVideoArray .objectAtIndex(indexPath.row) as! VideoData
cell.titleLabel.text = videoDataObj.videoTitle as String
cell.descLabel.text = videoDataObj.videoDesc as String
cell.playButton.tag = indexPath.row + (pageIndex * noOfElement)
let imageUrl = NSURL(string: videoDataObj.videoImage as String)
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)){
let data = NSData(contentsOfURL: imageUrl!)
dispatch_async(dispatch_get_main_queue(), {
cell.videoImageView?.contentMode = .ScaleToFill
cell.videoImageView?.image = UIImage(data: data!)
cell.setNeedsLayout()
cell.layoutIfNeeded()
})
}
return cell
}
Screen Shot Of View ist: enter image description here Vielen Dank im Voraus
** Niemals ** 'NSData (contentsOfURL:)' verwenden, um Daten aus dem Netzwerk zu laden, auch nicht in asynchron gesendeten Warteschlangen. Schau dir Apples [LazyTableImages] (https://developer.apple.com/library/ios/samplecode/LazyTableImages/Introduction/Intro.html) an, wie man Daten träge in eine Tabellenansicht lädt – vadian
Vielen Dank für deine sujjession vadian –