0

I want to be able to have a TextField in my static cells so I'm using the StringInputTableViewCell class from this demo: https://github.com/wannabegeek/PickerTableViewCell/tree/master/PickerCellDemo

I'm using storyboards and in my storyboard I got 2 cells that use the StringInputTableViewCell class. As you can see there is a UITextField property

@property (nonatomic, strong) UITextField *textField;

in StringInputTableViewCell.h. On storyboards in MyViewController I can connect the label, etc with a property but I cannot connect the TextField since its added in code and the TextField isn't on my storyboard. So my question is how do I get that property in MyViewController class?

4

1 回答 1

2

You can make your "StringInputTableViewCell" a property within your "MyViewController", or if you're trying to populate it during "cellForRowAtIndexPath", you can get get access to it through an identifier or a tag.

Once you have a pointer to the "StringInputTableViewCell" object that's being displayed in your table, you can then access the "textField" property of it in your code directly.

Something like:

StringInputTableViewCell * stringInputCell = (StringInputTableViewCell *) cell;
if(stringInputCell)
{
    stringInputCell.textField.text = @"Surprise, I can put text in here!";
}
于 2013-03-30T09:40:20.530 回答