iOS DropDown CocoaPod

iOS DropDown CocoaPod

我正在努力掌握 iOS DropDown cocoapod

import UIKit
import iOSDropDown

class CountryConfirmViewController: UIViewController {

    //var buttonTapped = 0

    @IBOutlet weak var countryLabel: DropDown!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        dropDown()
    }
            
    @IBAction func confirmCountry(_ sender: UIButton) {
        
        performSegue(withIdentifier: "goToUser", sender: self)
    }
           
    func dropDown() {
        countryLabel.optionArray = ["First", "Second", "Third"]
        countryLabel.showList()
    }
}

上面的代码生成了一个下拉菜单,但我无法获取用户选择的数据并将其移动到另一个控制器。我在 CocoaPod 网站上或其他任何地方都找不到任何相关信息。

您需要正确遵循相关库的文档,我找到了这个代码块;

dropDown.didSelect{(selectedText , index ,id) in
self.valueLabel.text = "Selected String: \(selectedText) \n index: \(index)"
}

您可以从方法didSelect

中抓取选择