I also face same problem few days ago, i write following code for this scenario, First i disable userinteraction on dataTextfield
but i have touch on complete UITableCell
. And i override simple UITouch
event method instead of textbegin delegate method. See my following code.
In tableviewController.h file
#import <UIKit/UIKit.h>
#import "CustomTableCell.h"
@class CustomTableCell;
@interface PersonalInfoTableViewController : UITableViewController<CustomTableCellDelegate>{
@property(nonatomic, strong) UITextField *previousTextField;
@end
In tableviewController.m file
@implementation TableViewController
@synthesize previousTextField;
//When you create custom table cell set your CustomcellDelegate = self in tableView:cellForRowAtIndexPath method\
//also assign previousTextField to CustomTableCell textfield
-(void)tableViewTouch{
[previousTextField resignFirstResponder];
}
in CustomTableCell.h file
#import <UIKit/UIKit.h>
@protocol CustomTableCellDelegate
@optional
-(void)tableViewTouch;
@end
@interface CustomTableCell : UITableViewCell<UITextFieldDelegate>
@property(nonatomic, unsafe_unretained) id<CustomTableCellDelegate> delegate;
@property(nonatomic, weak) IBOutlet UITextFiled *theCellTextField;
@end
in CustomTableCell.m file
@synthesize theCellTextField, delegate;
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
//Here my other method to show datepicker in popupViewController on tablecell.
[delegate tableViewTouch];
}
This is code for only ARC