[IOS] UITableViewController
UITableViewController can adapt to the keyboard itself (the focus of the control in the cell will be moved to the top of the keyboard
I thought about the following solution when I was doing keyboard retrieval:
1. Add a click event in tableview
Result: The didselect conflict between the Click Event and tableview, resulting in didselect failure.
2. scrollview
Result: The target can be achieved, but when you click textfield, the keyboard will appear and then be taken back directly. The reason is that the scrollview proxy is called.
Finally, the following solution is adopted:
_ SureBtn = [UIButton buttonWithType: UIButtonTypeCustom]; _ sureBtn. frame = CGRectMake (self. view. size. width-60, 5, 50, 28); _ sureBtn. backgroundColor = [UIColor colorWithRed: 0.150 green: 0.662 blue: 0.915 alpha: 1.000]; _ sureBtn. titleLabel. font = [UIFont systemFontOfSize: 15]; _ sureBtn. layer. cornerRadius = 5.0; [_ sureBtn setTitle: @ forState: UIControlStateNormal]; [_ sureBtn addTarget: self action: @ selector (changeRemarks) forControlEvents: UIControlEventTouchUpInside]; _ view = [[UIView alloc] initWithFrame: CGRectMake (0, 0, self. view. frame. size. width, 40)]; _ view. backgroundColor = [UIColor whiteColor]; UIView * line = [[UIView alloc] initWithFrame: CGRectMake (0, 0, self. view. frame. size. width, 0.5)]; line. backgroundColor = [UIColor blackColor]; [_ view addSubview: line]; [_ view addSubview: _ sureBtn];
In use, process Textfield as follows:
_begoodatField.inputAccessoryView = _view;
For the cell text box in tableview
You need to define a temporary textfield.
When using
_ XuexiaoField = cellMenu. celltext; _ xuexiaoField. inputAccessoryView = _ view; // cellMenu indicates the name of the custom cell.
Attach the confirmation button
- (void)changeRemarks{ [_nicktextField resignFirstResponder]; [_xuexiaoField resignFirstResponder]; [_begoodatField resignFirstResponder ]; [_bumenField resignFirstResponder ];}