diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index fbf7987e8c..4da16460b6 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -785,7 +785,6 @@ NSString * const kHotelFacilitiesSegue = @"Map2FacilitiesSegue"; self.visibleAreaKeyboard.constant = kbHeight; self.placePageAreaKeyboard.constant = kbHeight; } - [self.view layoutIfNeeded]; } #pragma mark - Properties diff --git a/iphone/Maps/Common/Keyboard/MWMKeyboard.h b/iphone/Maps/Common/Keyboard/MWMKeyboard.h index f0a371fc20..72103a84d7 100644 --- a/iphone/Maps/Common/Keyboard/MWMKeyboard.h +++ b/iphone/Maps/Common/Keyboard/MWMKeyboard.h @@ -12,8 +12,7 @@ - (instancetype)init __attribute__((unavailable("call +manager instead"))); - (instancetype)copy __attribute__((unavailable("call +manager instead"))); - (instancetype)copyWithZone:(NSZone *)zone __attribute__((unavailable("call +manager instead"))); -+ (instancetype)allocWithZone:(struct _NSZone *)zone -__attribute__((unavailable("call +manager instead"))); -+ (instancetype) new __attribute__((unavailable("call +manager instead"))); ++ (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable("call +manager instead"))); ++ (instancetype)new __attribute__((unavailable("call +manager instead"))); @end diff --git a/iphone/Maps/Common/Keyboard/MWMKeyboard.mm b/iphone/Maps/Common/Keyboard/MWMKeyboard.mm index 0ab86f6bca..e5049f44ef 100644 --- a/iphone/Maps/Common/Keyboard/MWMKeyboard.mm +++ b/iphone/Maps/Common/Keyboard/MWMKeyboard.mm @@ -1,24 +1,20 @@ #import "MWMKeyboard.h" -namespace -{ -using Observer = id; -using Observers = NSHashTable; -} // namespace - @interface MWMKeyboard () -@property(nonatomic) Observers * observers; +@property(nonatomic) NSHashTable *observers; @property(nonatomic) CGFloat keyboardHeight; @end @implementation MWMKeyboard -+ (void)applicationDidBecomeActive { [self manager]; } -+ (MWMKeyboard *)manager -{ - static MWMKeyboard * manager; ++ (void)applicationDidBecomeActive { + [self manager]; +} + ++ (MWMKeyboard *)manager { + static MWMKeyboard *manager; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ manager = [[self alloc] initManager]; @@ -26,81 +22,77 @@ using Observers = NSHashTable; return manager; } -- (instancetype)initManager -{ +- (instancetype)initManager { self = [super init]; - if (self) - { - _observers = [Observers weakObjectsHashTable]; - NSNotificationCenter * nc = NSNotificationCenter.defaultCenter; - [nc addObserver:self - selector:@selector(keyboardWillShow:) - name:UIKeyboardWillShowNotification - object:nil]; - - [nc addObserver:self - selector:@selector(keyboardWillHide:) - name:UIKeyboardWillHideNotification - object:nil]; + if (self) { + _observers = [NSHashTable weakObjectsHashTable]; + NSNotificationCenter *nc = NSNotificationCenter.defaultCenter; + [nc addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; + [nc addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; } return self; } -- (void)dealloc { [NSNotificationCenter.defaultCenter removeObserver:self]; } -+ (CGFloat)keyboardHeight { return [self manager].keyboardHeight; } +- (void)dealloc { + [NSNotificationCenter.defaultCenter removeObserver:self]; +} + ++ (CGFloat)keyboardHeight { + return [self manager].keyboardHeight; +} + #pragma mark - Add/Remove Observers -+ (void)addObserver:(id)observer -{ ++ (void)addObserver:(id)observer { [[self manager].observers addObject:observer]; } -+ (void)removeObserver:(id)observer -{ ++ (void)removeObserver:(id)observer { [[self manager].observers removeObject:observer]; } #pragma mark - Notifications -- (void)onKeyboardWillAnimate -{ - Observers * observers = self.observers.copy; - for (Observer observer in observers) - { +- (void)onKeyboardWillAnimate { + for (id observer in self.observers) { if ([observer respondsToSelector:@selector(onKeyboardWillAnimate)]) [observer onKeyboardWillAnimate]; } } -- (void)onKeyboardAnimation -{ - Observers * observers = self.observers.copy; - for (Observer observer in observers) +- (void)onKeyboardAnimation { + for (id observer in self.observers) { [observer onKeyboardAnimation]; + } } -- (void)keyboardWillShow:(NSNotification *)notification -{ +- (void)keyboardWillShow:(NSNotification *)notification { [self onKeyboardWillAnimate]; - CGSize const keyboardSize = - [notification.userInfo[UIKeyboardFrameBeginUserInfoKey] CGRectValue].size; + CGSize keyboardSize = [notification.userInfo[UIKeyboardFrameBeginUserInfoKey] CGRectValue].size; self.keyboardHeight = MIN(keyboardSize.height, keyboardSize.width); - NSNumber * rate = notification.userInfo[UIKeyboardAnimationDurationUserInfoKey]; - [UIView animateWithDuration:rate.floatValue + NSNumber *duration = notification.userInfo[UIKeyboardAnimationDurationUserInfoKey]; + NSNumber *curve = notification.userInfo[UIKeyboardAnimationCurveUserInfoKey]; + [UIView animateWithDuration:duration.doubleValue + delay:0 + options:curve.integerValue animations:^{ [self onKeyboardAnimation]; - }]; + } + completion:nil]; } -- (void)keyboardWillHide:(NSNotification *)notification -{ +- (void)keyboardWillHide:(NSNotification *)notification { [self onKeyboardWillAnimate]; self.keyboardHeight = 0; - NSNumber * rate = notification.userInfo[UIKeyboardAnimationDurationUserInfoKey]; - [UIView animateWithDuration:rate.floatValue + NSNumber *duration = notification.userInfo[UIKeyboardAnimationDurationUserInfoKey]; + NSNumber *curve = notification.userInfo[UIKeyboardAnimationCurveUserInfoKey]; + [UIView animateWithDuration:duration.doubleValue + delay:0 + options:curve.integerValue animations:^{ [self onKeyboardAnimation]; - }]; + } + completion:nil]; } @end