1

I've created a table view based on a feed that contains what is essentially a number of form type elements. Simplified think of it as containing two types of elements textboxes and messages. Textbox type cells should contain UITextFields and Message type cells contain a non editable UITextArea.

I have created a custom cell to handle each of the types and render them into a table. So far so good.

The client has requested a prev/next/done inputAccessoryView like the one that safari uses for html forms. A bit of work later I've got that up and running, I add some functionality that makes prev/next skip over message type cells and only call makeFirstResponder when it finds a textbox type cell. Still things seem to be going smoothly.

Then I added, in testing, a really long message to test my row height setting code. When I try to prev or next over this message cell it fails with a:

2012-02-21 11:34:36.642 MobileMarketing[52410:13a03] -[ContactFormTableViewController selectUpdate:]: unrecognized selector sent to instance 0x89802f0
2012-02-21 11:34:36.643 MobileMarketing[52410:13a03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ContactFormTableViewController selectUpdate:]: unrecognized selector sent to instance 0x89802f0'

I assume this is because the target field on the far side of the message and now offscreen has been dequeued. I'm reading up on that. But a long way around for a simple question. Does anyone have a good technique for dealing with this problem?

Brett Wagner
  • 1,134
  • 2
  • 10
  • 18

1 Answers1

1

If I'm understanding your problem correctly, you may be able to solve this using scrollToRowAtIndexPath:atScrollPosition:animated as seen here: https://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UITableView_Class/Reference/Reference.html.

If you scroll to the next cell, you can guarantee it exists before you try to makeFirstResponder.

Aaron
  • 6,988
  • 4
  • 31
  • 48
  • I was just trying the same big and still when I grab the cell it's not there (yet). I assume there is an event to hook when the scrolling is done, however. – Brett Wagner Feb 21 '12 at 20:01
  • `scrollViewDidEndScrollingAnimation:` ought to take care of that. http://stackoverflow.com/questions/4356256/how-to-get-notified-when-scrolltorowatindexpath-finishes-animating – Aaron Feb 21 '12 at 20:05
  • An unrelated bug was sending me into the weeds but this did solve my problem. As an aside an added wrinkle if scrollToRowAtIndexPath: does not cause actual scrolling then scrollViewDidEndScrollingAnimation: never gets called. – Brett Wagner Feb 21 '12 at 21:17