I have a custom UITableViewCell subclass, and a table view controller which I want to insert text boxes into.
What I have done is setup a three dimensional array to store the sections, rows and then in the third dimension I have put the placeholder text I would like to display –
In the custom UITableViewCell subclass I have defined the text box as a weak property (I think this is correct…?)
@property (weak) IBOutlet UITextField *plainTextField;
I then add this text field to my data model array in
cellForRowAtIndexPath:
however, when I try to access the textfield from my array (specifically plainTextField.text) I get
''
I get the feeling that something is being released somewhere and I can’t figure out where (the actual textfield is not nil)
I guess, my question is really a design one — how do you get UITextFields into a UITableViewController and then get the text out of them later….?
Thanks!
I’ve ‘fixed’ my problem — it’s really based on the fact that you can’t have different content in UITableViewCells, as soon as anything is different you have to load it in
cellForRowAtIndexPath. (A note in the UITableViewCell prepareForReuse method)What I did was reserve a spot in my data model for a UITextField, and then when cellForRowAtIndex path got to the cell it would query the data model, then instantiate a UITextField and add it to the
cell.contentViewor (here’s the tricky part) loop through[cell.contentview subviews]to find any UITextFields and callremoveFromSuperview