我在一个自定义的tableviewcell中有几个插座

class ShopTableViewCell: UITableViewCell {

    @IBOutlet var orderName: UITextField!

    @IBOutlet var specialinstructions: UITextField!
    @IBOutlet var shopName: UITextField!


}

我有一张
class ConvenienceTableViewController: UITableViewController, UITextFieldDelegate {

       override func viewDidLoad() {
        super.viewDidLoad()

       }

       func barTapped() {
         // I want to do some validation here, and getting the outlet's data from tableviewcell
       }

}

我唯一能想到的方法是使用
cell.orderName
cell.specialinstructions
cell.shopName

但是,我如何获取这些出口的数据并将其放入cellForRowAtIndexPath

最佳答案

let currentCell = tableView.cellForRowAtIndexPath(NSIndexPath(forRow: requiredRow, inSection: requiredSection)) as? ShopTableViewCell
let orderName = currentCell?.orderName

在你的barTapped中使用这个

关于ios - 如何从uitableviewcell到tableview获取导出的数据?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37741994/

10-12 04:01