Reputation: 13178
I have the following code:
@interface MyCell : UITableViewCell<UITextFieldDelegate>
{
IBOutlet UITextField *txtFields;
}
- (IBAction)textFieldAction:(id)sender;
@property (nonatomic,retain) IBOutlet UITextField *txtFields;
@end
I also have the following delegate function:
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
return NO;
}
However, I notice that it's NEVER being called. I set the delegate from the interface builder as well as from code as per: [txtFields setDelegate:self];
but neither seems to work. Is there something else i'm missing for this?
Upvotes: 0
Views: 1745
Reputation: 41622
You are obviously using this in conjunction with a UITableView
. First, if you want to support user interaction, the txtFields must be a subview of the cell's contentView
, not the backgroundView.
Assuming that the txtFields object is a subview of the contentView
, then lets look at the connections.
The tableView has a a method cellForRowAtIndexPath:
where you either return a new cell or a recycled cell. At the very bottom of that cell, add:
NSLog(@"textFields=%@ delegate=%@", cell.txtFields, cell.txtFields.delegate);
assert(cell.txtFields.delegate == cell); // lets make sure this is proper
If in fact both arguments are there, you now know that the txtFields object is in the proper container (contentView
), that the property is working, and that the delegate is set to the cell.
If that is all proper and you do not get the keyboard when you tap, then most likely something else is overlaying the txtFields - some other transparent view and its eating the touches.
In that case you should throw together a little demo app using the MyCell class, with even just one hardcoded cell, that demonstrates the problem, then upload that (zipped) to your DropBox account where others like myself can take a look at it and find the problem.
Upvotes: 6
Reputation: 66234
Try removing:
{ IBOutlet UITextField *txtFields; }
since you have a @property
already.
Also, did you @synthesize txtFields;
?
Upvotes: 0