Ich benutze Alamofire, um URL-Bild von JSON-Datei zu erhalten, und möchte das Bild, das ich von JSON zu Bildansicht in Zelle erhalten. Ich bin neu in der schnellen und schnellen Vernetzung.Das Bild in Zelle erscheint nicht
Mein Code auf MainCollectionViewController:
private let reuseIdentifier = "Cell"
class MainCollectionViewController: UICollectionViewController {
var result:String = ""
override func viewDidLoad() {
super.viewDidLoad()
}
override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of items
return 1
}
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! MainCollectionViewCell
Alamofire.request(.POST, "URL That Contain JSON").responseJSON { response in
if let value = response.result.value {
let json = JSON(value)
let data = json["data"].arrayValue
self.result = data[0]["image"].stringValue
print(self.result)
}
}
let imageName = (result)
cell.mainImageView.image = UIImage(named:imageName)
return cell
}
Und das Bild Auslass ist in MainCollectionViewCell:
class MainCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var mainImageView: UIImageView!
}
Der Build succeded aber das Bild nicht erscheint, zeigt Zelle ohne im Inneren Bild.
get thread 1: Signal SIGABRT –
hast du das Problem gelöst? –