У меня есть UITableView для каждой строки, в которой есть текстовое поле. Когда пользователь вводит что-то в текстовое поле, я хочу вызвать это textFieldDidChange или что-то еще. В основном, когда изменяется текстовое поле, я хочу что-то вычислить, как я могу это сделать? Я использую swift.
Вот часть моего кода:
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if(tableView == self.seatsDropDownTblView){
return seatsList!.count
}else{
return priceList!.count
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if tableView == self.seatsDropDownTblView {
let seats_cell = tableView.dequeueReusableCell(withIdentifier: "SeatsCell", for: indexPath) as! SeatsCell
seats_cell.seatsCountLbl.text = self.seatsList?[indexPath.row]
seats_cell.selectionStyle = .none
return seats_cell
}else {
let price_cell = tableView.dequeueReusableCell(withIdentifier: "AddPriceCell", for: indexPath) as! AddPriceCell
price_cell.txtPrice.text = priceList?[indexPath.row].Price
price_cell.dropOffPointLbl.text = priceList?[indexPath.row].DropPoint
self.indexPathArray.append(indexPath as NSIndexPath)
price_cell.txtPrice.tag = indexPath.row
//Delegates
price_cell.txtPrice.delegate = self
//Assign Delegates
price_cell.txtPrice.delegate = self
price_cell.selectionStyle = .none
return price_cell
}
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if tableView == self.seatsDropDownTblView {
//let seats_cell = tableView.dequeueReusableCell(withIdentifier: "SeatsCell", for: indexPath) as! SeatsCell
//seats_cell.selectionStyle = .none
self.selectedSeat = (self.seatsList?[indexPath.row])!
self.selectedSeatLbl.text = self.selectedSeat
self.seatsDropDownView.isHidden = true
isDropDownFalls = true
self.dropDownBtnImg.image = UIImage(named:"drop_down")
}else {
let cell = tableView.cellForRow(at: indexPath) as! AddPriceCell
cell.selectionStyle = .none
}
}
func textFieldDidChange(_ textField: UITextField) {
NSLog("Event Triggered")
}
Этот делегат не активируется. Я также импортирую протокол UITextFieldDelegate. Любое предложение?
textFieldDidChange
внутри cellForRowAt - person Anbu.Karthik   schedule 10.08.2017AddPriceCell
? - person Akhilrajtr   schedule 10.08.2017