Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to handle events (Touch Up Inside/Outside) for UItableViewCell with a text field?
    text
    copied!<p>I have a custom UITableViewCell which has a text field inside it. I have created it using IB and have a custom class with it.</p> <p>Now, my issue is that I want to setup the text field so that during text entry if the user clicks outside the text field (without hitting the return/done key on the keypad), the field resigns first responder. I understand, that do that I need to handle the Touch Up Inside Event. However my tableview class never receives this event even though I have done the connections. I am assuming that its because its not subclass of UIcontrol, which I cant make it as it needs to be UITableViewCel.</p> <p>So whats the solution?? How do I receive these events??</p> <p>Header File:</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface MMSingleTextFieldCell : UITableViewCell &lt;UITextFieldDelegate&gt; // Properties @property (weak, nonatomic) IBOutlet UITextField *singleTextField; // Methods - (IBAction)eventTouchUpOutside:(id)sender; - (IBAction)eventTouchUpInside:(id)sender; @end </code></pre> <p>Class File:</p> <pre><code>#import "MMSingleTextFieldCell.h" @implementation MMSingleTextFieldCell @synthesize singleTextField; - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { // Initialization code } return self; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } - (IBAction)eventTouchUpOutside:(id)sender { [singleTextField resignFirstResponder]; } - (IBAction)eventTouchUpInside:(id)sender { [singleTextField resignFirstResponder]; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload