Remélem nektek már van egy megoldás olvasás mindazok. De találtam én megoldásom a következő. Várom, hogy már van egy sejtet UITextField. Így a felkészülés csak tartsa sorindex a beviteli mezőbe a tag.
cell.textField.tag = IndexPath.row;
Hozzon létre egy activeTextField, példányának UITextFieldglobális köre az alábbiak szerint:
@interface EditViewController (){
UITextField *activeTextField;
}
Szóval, most már csak másold be a kódomat a végén. És ne felejtsük el, hogy adjunkUITextFieldDelegate
#pragma mark - TextField Delegation
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
activeTextField = textField;
return YES;
}
- (void)textFieldDidEndEditing:(UITextField *)textField{
activeTextField = nil;
}
regiszterek billentyűzet notifications
#pragma mark - Keyboard Activity
- (void)registerForKeyboardNotifications
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasShown:)
name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillBeHidden:)
name:UIKeyboardWillHideNotification object:nil];
}
Fogantyúk billentyűzet Notifications:
Meghívásra, ha a UIKeyboardDidShowNotificationküldött.
- (void)keyboardWasShown:(NSNotification*)aNotification
{
NSDictionary* info = [aNotification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, kbSize.height, 0.0);
[self.tableView setContentInset:contentInsets];
[self.tableView setScrollIndicatorInsets:contentInsets];
NSIndexPath *currentRowIndex = [NSIndexPath indexPathForRow:activeTextField.tag inSection:0];
[self.tableView scrollToRowAtIndexPath:currentRowIndex atScrollPosition:UITableViewScrollPositionTop animated:YES];
}
Meghívásra, ha a UIKeyboardWillHideNotificationküldött
- (void)keyboardWillBeHidden:(NSNotification*)aNotification
{
UIEdgeInsets contentInsets = UIEdgeInsetsZero;
[self.tableView setContentInset:contentInsets];
[self.tableView setScrollIndicatorInsets:contentInsets];
}
Most egy dolog van hátra, hívja a registerForKeyboardNotificationsmódszert, hogy ViewDidLoada módszer a következő:
- (void)viewDidLoad {
[super viewDidLoad];
// Registering keyboard notification
[self registerForKeyboardNotifications];
// Your codes here...
}
Kész, remélem, a textFieldsjövőben nem rejti el a billentyűzetet.