I am having a heck of time with this. Using storyboard, I created a table view controller with a static cell that contains a UITextField to allow for user input. When the user is finished, I want to retrieve the contents of the text field.
Here is what I did:
UITableViewCell
named SingleLineFieldTableViewCell
IBOutlet UITextField *textField;
to the subclass and declared it as a property (nonatomic, retain) and synthesized it.Added IBOutlet SingleLineFieldTableViewCell *cellNamed;
to the owning table view controller, and declared it as a property (nonatomic, retain) and synthesized it.
In storyboard, I have a table view controller with static cells. One of the cells is the custom cell, which is declared as SingleLineFieldTableViewCell
and owns a UITextField
. It is also assigned a cell identifier.
When I run, dequeueReusableCellWithIdentifier
returns nil
. I thought that with Xcode 4 and storyboards, dequeueReusableCellWithIdentifier
, according to Converting to Storyboards Release Notes, "The dequeueReusableCellWithIdentifier:
method is guaranteed to return a cell (provided that you have defined a cell with the given identifier)".
The weird part is that when I run in the Simulatior, the table appears as expected (section, cell size, etc.), except that I can't edit the custom cell.
I'm at a loss. Any help or ideas?
--John
I know this question was a year ago, but I just went through this problem myself today.
I think the problem here is using static cells.
See the Apple docs: http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/tableview_iphone/TableViewCells/TableViewCells.html
Basically the idea is that if you are using static cells then there is no need to use
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
data source method, instead just generate outlets to all your UI elements (inside the static cells) and set them directly.
If you need to use this method then you must change the table to dynamic content mode.
Are you building for iOS 5 or 4?
If you are trying with 4.x it won't crash as the method is valid, but doesn't return the cell. I have had no problem setting it up with custom classes. here is my entire method:
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
GameDetailCell* cell=[tableView dequeueReusableCellWithIdentifier:@"gameCell"];
[self configureCell:cell atIndexPath:indexPath];
return cell;
}
my storyboard looks like:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With