You can save the indexPath of the cell that user is editing. Then when he scrolls test if that cell is in visible cells of the tableView. If not get the text field from that cell and dismiss the keyboard.
Up vote 0 down vote favorite share g+ share fb share tw.
I have a UITableView with a whole bunch of custom UITableViewCells in it. Each of these UITableViewCells has a UITextView in them. The problem I'm having, is that if the user touches a UITextView, that becomes the firstResponder and the keyboard pops up.
If the user then scrolls down to a point where the UITableViewCell that the firstResponder is on is no longer on the screen, I can't get at the UITextView to dismiss it. I've tried holding (and retaining) a reference to the UITextView, but as soon as it leaves the screen and I try to access it I get an EXC_BAD_ACCESS. This happens no matter how many times I retain it, so I suspect it may be having dealloc called directly on it (I'm not sure how the cell dequeueing system actually works).
The other weird thing is that if I scroll the UITextField off screen, the keyboard can still be used to write to it, and the text typed is visible when I scroll back to the UITextField. Any help would be much appreciated. Iphone objective-c uitableviewcell uitextfield firstresponder link|improve this question edited Feb 15 '11 at 7:20Robin5,6613828 asked Feb 15 '11 at 7:11user107268962.
You can save the indexPath of the cell that user is editing. Then when he scrolls test if that cell is in visible cells of the tableView. If not get the text field from that cell and dismiss the keyboard.
UITableViewCell *editingCell = self. TableView cellForRowAtIndexPath:SavedIndexPath; editingCell. TextField resignFirstResponder.
Tried your method, but it seems that the cause of this buggy behavior was something entirely different. Thanks anyway! – user1072689 Feb 16 '11 at 1:00 and what was your solution?
– Eric Mar 21 at 3:10.
Fluchtpunkt was absolutely correct, I wasn't re-using my cells correctly. My problem was that I was loading my custom UITableViewCells from a nib using the method: static NSString *CellIdentifier = @"CustomCell"; ExpandingTableViewCell *cell = (ExpandingTableViewCell *)tableView dequeueReusableCellWithIdentifier:CellIdentifier; if (cell == nil) { NSArray *nib = NSBundle mainBundle loadNibNamed:@"ExpandingTableViewCell" owner:self options:nil; cell = (ExpandingTableViewCell *)nib objectAtIndex:0; } I didn't realize that I had to set the Identifier field in the . Xib file for the custom cell to CustomCell.
As soon as my cells were being re-used properly, the problem with the UITextField being dealloc'd before its time disappeared.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.