You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!I am working with tmdb API and want to display some movies on a cards depending on a query(For now I try to display only one card in order to test it first).I followed the instructions on main page of this repo, and everything is fine description is displayed and I can swipe this View, except image doesn't display.Please help me if you can.Thank you!
`
import UIKit
import Shuffle_iOS
class ResultViewController: UIViewController {
let cardStack = SwipeCardStack()
var cardImages = [UIImage](){didSet {
DispatchQueue.main.async {
self.cardStack.reloadData()
}
}}
var name:String = ""
var releaseDate:String = ""
var popularity:Double = 0.0
var voteAverage:Double = 0.0
var budget:Int = 0
var revenue:Int = 0
var overview:String = ""
var url:URL!
var image:UIImage!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var ratingLabel: UILabel!
@IBOutlet weak var budgetLabel: UILabel!
@IBOutlet weak var overviewLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(cardStack)
cardStack.frame = view.safeAreaLayoutGuide.layoutFrame
cardStack.dataSource = self
}
override func viewWillAppear(_ animated: Bool) {
if url != nil{
downloadImage(from: url)
DispatchQueue.main.async {
self.titleLabel.text = self.name + "(" + self.releaseDate + ")"
self.ratingLabel.text = String(self.popularity) + " " + String(self.voteAverage)
self.budgetLabel.text = "Budget: " + String(self.budget) + "Revenue: " + String(self.revenue)
self.overviewLabel.text = self.overview
}
}
}
Hi!I am working with tmdb API and want to display some movies on a cards depending on a query(For now I try to display only one card in order to test it first).I followed the instructions on main page of this repo, and everything is fine description is displayed and I can swipe this View, except image doesn't display.Please help me if you can.Thank you!
`
import UIKit
import Shuffle_iOS
class ResultViewController: UIViewController {
let cardStack = SwipeCardStack()
}
extension ResultViewController{
func getData(from url: URL, completion: @escaping (Data?, URLResponse?, Error?) -> ()) {
URLSession.shared.dataTask(with: url, completionHandler: completion).resume()
}
func downloadImage(from url: URL) {
getData(from: url) { data, response, error in
guard let data = data, error == nil else { return }
DispatchQueue.main.async() {
let image = UIImage(data: data)
if image != nil{
self.cardImages.append(image!)
print(self.cardImages)
}
extension ResultViewController:SwipeCardStackDataSource{
func cardStack(_ cardStack: SwipeCardStack, cardForIndexAt index: Int) -> SwipeCard {
return card(fromImage: cardImages[index])
}
}
`
The text was updated successfully, but these errors were encountered: