Я использую библиотеку Koloda (https://github.com/Yalantis/Koloda), чтобы отображать данные в виде салфетки.Использование библиотеки Koloda с источником данных Parse
import UIKit
import Koloda
import pop
import Parse
import Bolts
import ParseUI
private var numberOfCards: UInt = 5
class ViewController: UIViewController, KolodaViewDataSource, KolodaViewDelegate {
var ids : [String] = []
@IBOutlet weak var kolodaView: KolodaView!
@IBAction func undo(sender: AnyObject) {
kolodaView?.revertAction()
}
@IBAction func left(sender: AnyObject) {
kolodaView?.swipe(SwipeResultDirection.Left)
}
@IBAction func right(sender: AnyObject) {
kolodaView?.swipe(SwipeResultDirection.Right)
}
override func viewDidLoad() {
super.viewDidLoad()
kolodaView.dataSource = self
kolodaView.delegate = self
self.modalTransitionStyle = UIModalTransitionStyle.FlipHorizontal
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
//MARK: KolodaViewDataSource
func kolodaNumberOfCards(koloda: KolodaView) -> UInt {
return numberOfCards
}
func kolodaViewForCardAtIndex(koloda: KolodaView, index: UInt) -> UIView {
return UIImageView(image: UIImage(named: "Card_like_\(index + 1)"))
}
func kolodaViewForCardOverlayAtIndex(koloda: KolodaView, index: UInt) -> OverlayView? {
return NSBundle.mainBundle().loadNibNamed("OverlayView",
owner: self, options: nil)[0] as? OverlayView
}
//MARK: KolodaViewDelegate
func kolodaDidSwipedCardAtIndex(koloda: KolodaView, index: UInt, direction: SwipeResultDirection) {
//Example: loading more cards
if index >= 3 {
numberOfCards = 6
kolodaView.reloadData()
}
}
func kolodaDidRunOutOfCards(koloda: KolodaView) {
//Example: reloading
kolodaView.resetCurrentCardNumber()
}
func kolodaDidSelectCardAtIndex(koloda: KolodaView, index: UInt) {
UIApplication.sharedApplication().openURL(NSURL(string: "http://yalantis.com/")!)
}
func kolodaShouldApplyAppearAnimation(koloda: KolodaView) -> Bool {
return true
}
func kolodaShouldMoveBackgroundCard(koloda: KolodaView) -> Bool {
return true
}
func kolodaShouldTransparentizeNextCard(koloda: KolodaView) -> Bool {
return true
}
func kolodaBackgroundCardAnimation(koloda: KolodaView) -> POPPropertyAnimation? {
return nil
}
}
Приведенный выше код отлично работает с шестью изображениями, которые я сохранил в активах. Я хочу заполнить каждую карту данными из ParseUser (Текст и изображение). Я думал о чем-то подобном заполнении tableView с ParseData, но я не могу найти правильное решение. Это цель KolodaView:
KolodaView - это класс, предназначенный для упрощения реализации Tinder-карт на iOS. Он добавляет удобные функциональные возможности, такие как интерфейс данных/делегата в стиле UITableView, для динамического загрузки представлений и эффективной загрузки, разгрузки.
Возможно, есть и другая библиотека, чтобы сделать то же самое.