Managing Delegate of UITextFields in Custom UITableViewCell

后端 未结 5 1556
长情又很酷
长情又很酷 2021-01-17 13:05

So I have looked around a quite a bit, and nothing on here seems to explain exactly the correct way of doing this. I have 7 UITextFields within a custom UITableViewCell.

5条回答
  •  一生所求
    2021-01-17 14:01

    Swift version (Based on Eyal's answer)

    class MyViewController: UIViewController, ... , UITextFieldDelegate {
    
        @IBOutlet var activeTextField: UITextField!  //doesn't need to connect to the outlet of textfield in storyboard
    
        ....
    
        func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    
        ....
    
        var cellTextField = self.view.viewWithTag(101) as? UITextField
        cellTextField!.delegate = self;
        ....
    }
    

提交回复
热议问题