diff --git a/iphone/Maps/Classes/MWMBookmarkDescriptionViewController.mm b/iphone/Maps/Classes/MWMBookmarkDescriptionViewController.mm index c783ab3cd3..014eb08949 100644 --- a/iphone/Maps/Classes/MWMBookmarkDescriptionViewController.mm +++ b/iphone/Maps/Classes/MWMBookmarkDescriptionViewController.mm @@ -47,6 +47,11 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState) self.navigationItem.title = L(@"description"); MWMPlacePageEntity const * entity = self.manager.entity; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(keyboardWillChangeFrame:) + name:UIKeyboardWillChangeFrameNotification + object:nil]; + if (entity.isHTMLDescription) self.state = BookmarkDescriptionStateViewHTML; else @@ -59,14 +64,6 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState) [self.navigationItem setLeftBarButtonItem:leftButton]; return; } - - if (!IPAD) - { - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(keyboardWillChangeFrame:) - name:UIKeyboardWillChangeFrameNotification - object:nil]; - } } - (void)viewWillAppear:(BOOL)animated @@ -106,7 +103,6 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState) { self.textView.hidden = NO; self.textView.text = text; - [self.textView becomeFirstResponder]; [UIView animateWithDuration:kDefaultAnimationDuration animations:^ { self.webView.alpha = 0.; @@ -115,6 +111,7 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState) completion:^(BOOL finished) { self.webView.hidden = YES; + [self.textView becomeFirstResponder]; }]; [self configureNavigationBarForEditing]; } @@ -174,6 +171,7 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState) - (void)backTap { + [self.textView resignFirstResponder]; [self popViewController]; } @@ -207,13 +205,13 @@ typedef NS_ENUM(NSUInteger, BookmarkDescriptionState) NSDictionary * info = [aNotification userInfo]; CGSize const kbSize = [info[UIKeyboardFrameEndUserInfoKey] CGRectValue].size; CGFloat const offsetToKeyboard = 8.0; - self.textViewBottomOffset.constant = kbSize.height + offsetToKeyboard; + CGFloat const navBarHeight = IPAD ? self.navigationController.navigationBar.height : 0.0; + self.textViewBottomOffset.constant = kbSize.height + offsetToKeyboard - navBarHeight; } - (void)dealloc { - if (!IPAD) - [[NSNotificationCenter defaultCenter] removeObserver:self]; + [[NSNotificationCenter defaultCenter] removeObserver:self]; } #pragma mark - UIWebViewDelegate diff --git a/iphone/Maps/Classes/MWMPlacePage.h b/iphone/Maps/Classes/MWMPlacePage.h index 8b257bea09..76e33ae758 100644 --- a/iphone/Maps/Classes/MWMPlacePage.h +++ b/iphone/Maps/Classes/MWMPlacePage.h @@ -41,7 +41,8 @@ - (void)setDistance:(NSString *)distance; - (void)updateMyPositionStatus:(NSString *)status; -- (void)keyboardWillChangeFrame:(NSNotification *)aNotification; +- (void)keyboardWillShow:(NSNotification *)aNotification; +- (void)keyboardWillHide; - (instancetype)init __attribute__((unavailable("call initWithManager: instead"))); diff --git a/iphone/Maps/Classes/MWMPlacePage.mm b/iphone/Maps/Classes/MWMPlacePage.mm index bc6de72ac6..c2c10d8747 100644 --- a/iphone/Maps/Classes/MWMPlacePage.mm +++ b/iphone/Maps/Classes/MWMPlacePage.mm @@ -37,8 +37,8 @@ static NSString * const kPlacePageViewCenterKeyPath = @"center"; context:nullptr]; } [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(keyboardWillChangeFrame:) - name:UIKeyboardWillChangeFrameNotification + selector:@selector(keyboardWillShow:) + name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self @@ -58,7 +58,7 @@ static NSString * const kPlacePageViewCenterKeyPath = @"center"; [[NSNotificationCenter defaultCenter] removeObserver:self]; } -- (void)keyboardWillChangeFrame:(NSNotification *)aNotification +- (void)keyboardWillShow:(NSNotification *)aNotification { NSDictionary * info = [aNotification userInfo]; self.keyboardHeight = [info[UIKeyboardFrameEndUserInfoKey] CGRectValue].size.height; @@ -185,6 +185,11 @@ static NSString * const kPlacePageViewCenterKeyPath = @"center"; [self.basePlacePageView reloadBookmarkCell]; } +- (void)willStartEditingBookmarkTitle +{ +// This method should be ovverriden. +} + - (void)willFinishEditingBookmarkTitle:(NSString *)title { self.basePlacePageView.titleLabel.text = title; diff --git a/iphone/Maps/Classes/MWMTextView.mm b/iphone/Maps/Classes/MWMTextView.mm index 98abffe3ca..8e94a4d58f 100644 --- a/iphone/Maps/Classes/MWMTextView.mm +++ b/iphone/Maps/Classes/MWMTextView.mm @@ -9,25 +9,7 @@ @implementation MWMTextView -- (instancetype)initWithCoder:(NSCoder *)coder -{ - self = [super initWithCoder:coder]; - if (self) - [self prepare]; - - return self; -} - -- (instancetype)initWithFrame:(CGRect)frame textContainer:(NSTextContainer *)textContainer -{ - self = [super initWithFrame:frame textContainer:textContainer]; - if (self) - [self prepare]; - - return self; -} - -- (void)prepare +- (void)awakeFromNib { [self setTextContainerInset:UIEdgeInsetsZero]; diff --git a/iphone/Maps/Classes/MWMiPadPlacePage.mm b/iphone/Maps/Classes/MWMiPadPlacePage.mm index 70a5082ec4..e17b22e061 100644 --- a/iphone/Maps/Classes/MWMiPadPlacePage.mm +++ b/iphone/Maps/Classes/MWMiPadPlacePage.mm @@ -219,9 +219,7 @@ static CGFloat const kKeyboardOffset = 12.; { [UIView animateWithDuration:animated ? kDefaultAnimationDuration : 0.0 animations:^ { - CGFloat const actionBarHeight = self.actionBar.height; - self.height = self.basePlacePageView.height + self.anchorImageView.height + actionBarHeight - 1; - self.actionBar.origin = CGPointMake(0., self.height - actionBarHeight); + self.height = self.basePlacePageView.height + self.anchorImageView.height + self.actionBar.height - 1; [self updatePlacePagePosition]; }]; } @@ -255,9 +253,15 @@ static CGFloat const kKeyboardOffset = 12.; } } -- (void)keyboardWillChangeFrame:(NSNotification *)aNotification +- (void)keyboardWillShow:(NSNotification *)aNotification { - [super keyboardWillChangeFrame:aNotification]; + [super keyboardWillShow:aNotification]; + [self updateHeight]; +} + +- (void)keyboardWillHide +{ + [super keyboardWillHide]; [self updateHeight]; } @@ -281,6 +285,7 @@ static CGFloat const kKeyboardOffset = 12.; _height = MIN(_height, [self getAvailableHeight]); self.navigationController.view.height = _height; self.extendedPlacePageView.height = _height; + self.actionBar.origin = CGPointMake(0., _height - self.actionBar.height); } - (MWMiPadNavigationController *)navigationController