2

我正在构建一个类似 tinder 的应用程序,并且我正在使用一个库 KolodaView:https ://github.com/Yalantis/Koloda

在库中,它们具有功能设置,因此当您选择 UIView 时,它会触发一个动作。目前它的设置是打开一个 URL。如下图所示:

extension ViewController: KolodaViewDelegate {

func kolodaDidRunOutOfCards(_ koloda: KolodaView) {
    print("Out of cards")
}

func koloda(_ koloda: KolodaView, didSelectCardAt index: Int) {
    UIApplication.shared.openURL(URL(string: "https://yalantis.com/")!)
}

func koloda(_ koloda: KolodaView, didSwipeCardAt index: Int, in direction: SwipeResultDirection) {

    let x = data[index]
    print("did swipe \(x) in diredtion: \(direction)")
}

}

我该如何设置,以便当您点击 UIView 时它会展开/折叠并因此显示更多信息。基本上像手风琴一样工作。扩展 UIView 显示的信息最好来自 XIB 文件视图。

我已经在另一个 XIB 文件视图的数据源中设置了主 UIView。

 extension ViewController: KolodaViewDataSource {

func kolodaNumberOfCards(_ koloda: KolodaView) -> Int {
    return data.count
}

func koloda(_ koloda: KolodaView, viewForCardAt index: Int) -> UIView {

    let swipeView = Bundle.main.loadNibNamed("SwipeView", owner: self, options: nil)![0] as! SwipeView
    let x = data[index]

    //        swipeView.setupView(job: x)


    return swipeView
}

func kolodaSpeedThatCardShouldDrag(_ koloda: KolodaView) -> DragSpeed {
    return .default
}

}

我对 swift 很陌生,任何帮助都将不胜感激。

4

0 回答 0