diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/PlacePage/Cells/OpeningHours/MWMPlacePageOpeningHoursCell.xib b/iphone/Maps/Classes/CustomViews/MapViewControls/PlacePage/Cells/OpeningHours/MWMPlacePageOpeningHoursCell.xib index 986598a5a1..ea74f1ff81 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/PlacePage/Cells/OpeningHours/MWMPlacePageOpeningHoursCell.xib +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/PlacePage/Cells/OpeningHours/MWMPlacePageOpeningHoursCell.xib @@ -1,5 +1,5 @@ - + @@ -143,6 +143,7 @@ + @@ -226,7 +227,7 @@ - + diff --git a/iphone/Maps/Classes/Editor/MWMEditorCommon.h b/iphone/Maps/Classes/Editor/MWMEditorCommon.h index 3c22355996..953f570034 100644 --- a/iphone/Maps/Classes/Editor/MWMEditorCommon.h +++ b/iphone/Maps/Classes/Editor/MWMEditorCommon.h @@ -1,5 +1,6 @@ @protocol MWMEditorCellProtocol +- (void)cellBeginEditing:(UITableViewCell *)cell; - (void)cell:(UITableViewCell *)cell changeText:(NSString *)changeText; - (void)cell:(UITableViewCell *)cell changeSwitch:(BOOL)changeSwitch; - (void)cellSelect:(UITableViewCell *)cell; diff --git a/iphone/Maps/Classes/Editor/MWMEditorNameTableViewCell.xib b/iphone/Maps/Classes/Editor/MWMEditorNameTableViewCell.xib index d3916385a8..fc94000615 100644 --- a/iphone/Maps/Classes/Editor/MWMEditorNameTableViewCell.xib +++ b/iphone/Maps/Classes/Editor/MWMEditorNameTableViewCell.xib @@ -1,5 +1,5 @@ - + @@ -42,7 +42,7 @@ - + @@ -75,7 +75,7 @@ - + diff --git a/iphone/Maps/Classes/Editor/MWMEditorTextTableViewCell.mm b/iphone/Maps/Classes/Editor/MWMEditorTextTableViewCell.mm index 204b16e4cf..60a2f76123 100644 --- a/iphone/Maps/Classes/Editor/MWMEditorTextTableViewCell.mm +++ b/iphone/Maps/Classes/Editor/MWMEditorTextTableViewCell.mm @@ -36,11 +36,18 @@ #pragma mark - UITextFieldDelegate +- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField +{ + [self.delegate cellBeginEditing:self]; + return YES; +} + - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { - NSString * newString = [textField.text stringByReplacingCharactersInRange:range withString:string]; + NSString * newString = + [textField.text stringByReplacingCharactersInRange:range withString:string]; BOOL const isCorrect = [textField.validator validateString:newString]; if (isCorrect) [self.delegate cell:self changeText:newString]; diff --git a/iphone/Maps/Classes/Editor/MWMEditorViewController.mm b/iphone/Maps/Classes/Editor/MWMEditorViewController.mm index 1ed7d55bb3..120f69a1d8 100644 --- a/iphone/Maps/Classes/Editor/MWMEditorViewController.mm +++ b/iphone/Maps/Classes/Editor/MWMEditorViewController.mm @@ -73,6 +73,7 @@ NSString * reuseIdentifier(MWMPlacePageCellType cellType) @property (weak, nonatomic) IBOutlet NSLayoutConstraint * tableViewBottomOffset; @property (nonatomic) NSMutableDictionary * offscreenCells; +@property (weak, nonatomic) UITableViewCell * editCell; @property (nonatomic) BOOL needsReload; @@ -130,14 +131,25 @@ NSString * reuseIdentifier(MWMPlacePageCellType cellType) NSDictionary * info = [aNotification userInfo]; CGFloat const kbYEnd = [info[UIKeyboardFrameEndUserInfoKey] CGRectValue].origin.y; CGFloat const kbYBeg = [info[UIKeyboardFrameBeginUserInfoKey] CGRectValue].origin.y; - UIViewAnimationCurve const curve = static_cast([info[UIKeyboardAnimationCurveUserInfoKey] integerValue]); + UIViewAnimationCurve const curve = + static_cast([info[UIKeyboardAnimationCurveUserInfoKey] integerValue]); NSTimeInterval const duration = [info[UIKeyboardAnimationDurationUserInfoKey] doubleValue]; [self.view layoutIfNeeded]; - self.tableViewBottomOffset.constant = kbYEnd < kbYBeg ? kbYBeg - kbYEnd : 0.0; + UITableView * tv = self.tableView; + NSIndexPath * cellPath = [tv indexPathForCell:self.editCell]; + [tv scrollToRowAtIndexPath:cellPath atScrollPosition:UITableViewScrollPositionNone animated:YES]; + if (kbYEnd < kbYBeg) + self.tableViewBottomOffset.constant = kbYBeg - kbYEnd; + else if (kbYEnd > kbYBeg) + self.tableViewBottomOffset.constant = 0.0; [UIView animateWithDuration:duration delay:0.0 options:curve animations:^ { [self.view layoutIfNeeded]; - } completion:nil]; + } + completion:^(BOOL finished) + { + [tv scrollToRowAtIndexPath:cellPath atScrollPosition:UITableViewScrollPositionNone animated:YES]; + }]; } #pragma mark - Actions @@ -477,6 +489,11 @@ NSString * reuseIdentifier(MWMPlacePageCellType cellType) #pragma mark - MWMEditorCellProtocol +- (void)cellBeginEditing:(UITableViewCell *)cell +{ + self.editCell = cell; +} + - (void)cell:(UITableViewCell *)cell changeText:(NSString *)changeText { NSIndexPath * indexPath = [self.tableView indexPathForCell:cell]; diff --git a/iphone/Maps/Classes/MWMPlacePageButtonCell.xib b/iphone/Maps/Classes/MWMPlacePageButtonCell.xib index 40a7814ae2..8f6d254458 100644 --- a/iphone/Maps/Classes/MWMPlacePageButtonCell.xib +++ b/iphone/Maps/Classes/MWMPlacePageButtonCell.xib @@ -1,5 +1,5 @@ - + @@ -17,7 +17,7 @@