Merge pull request #341 from igrechuhin/ig-master

[ios] Fixed place page description layout.
This commit is contained in:
Vlad Mihaylenko 2015-10-22 12:43:06 +03:00
commit 1c17390818
5 changed files with 31 additions and 40 deletions

View file

@ -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

View file

@ -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")));

View file

@ -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;

View file

@ -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];

View file

@ -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