I have a table view. In that I am creating the UITextField
dynamically.
But I am not able to fire the events in it.
func tableView(_ tableView: UITableView, cellForRowAt indexPath:IndexPath) -> UITableViewCell {
let cell = self.tableView.dequeueReusableCell(withIdentifier: "cell",for: indexPath) as! DynamicTableCell
var dynamicTxtField1: UITextField = UITextField()
dynamicTxtField1.backgroundColor = UIColor.white
dynamicTxtField1.rightViewMode = .always
dynamicTxtField1.layer.cornerRadius = 5;
dynamicTxtField1.clipsToBounds = true
dynamicTxtField1.borderStyle = .roundedRect
// Here i am not able to assign the
//Error in this line // dynamicTxtField1.delegate = self
// Here object "self" is referring to the view. Because of this i am not able to fire any events of the UITextField
cell.addSubview(dynamicTxtField1)
}
Please suggest how to assign the delegate to the UITextField in this scenario so that I can fire an event to show a view to pick some values from it.
The error is:
"Cannot assign the value of ViewName(classname) to type UITextFieldDelegate"
on the line:
dynamicTxtField1.delegate = self