Skip to content
This repository has been archived by the owner on Jul 25, 2019. It is now read-only.

TWEAK: showing description on forms for all but one device/orientatio… #398

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions Classes/UVDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

#define SCREEN4ORLOWERLANDSCAPE ([[UIScreen mainScreen] bounds].size.height <= 320)
31 changes: 19 additions & 12 deletions Classes/UVPostIdeaViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,21 @@ - (void)loadView {
[self registerForKeyboardNotifications];
_didAuthenticateCallback = [[UVCallback alloc] initWithTarget:self selector:@selector(createSuggestion)];
[self updateLayout];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];
}

-(void)didRotate:(id)sender{
[self updateLayout];
[_fieldsView performSelector:@selector(updateLayout) withObject:nil afterDelay:0];
}

- (void)updateLayout {
_topConstraint.constant = (IOS7 ? (IPAD ? 44 : (UIInterfaceOrientationIsPortrait(self.interfaceOrientation) ? 64 : 52)) : 0);
if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation) || IPAD) {

_desc.hidden = NO;
[self.view removeConstraint:_descConstraint];
} else {
_desc.hidden = YES;
[self.view addConstraint:_descConstraint];

}
if (!IOS7) {
_desc.preferredMaxLayoutWidth = 0;
Expand All @@ -136,17 +141,19 @@ - (void)updateLayout {
}
}

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
[self updateLayout];
[_fieldsView performSelector:@selector(updateLayout) withObject:nil afterDelay:0];
}

- (void)keyboardDidShow:(NSNotification *)note {
if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation) || IPAD) {
_keyboardConstraint.constant = -_kbHeight-10;
// fine tune the offsets so the description shows well above landscape in different device sizes

int heightOffset = 20;
if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) {
if(IPAD){
heightOffset = 50;
}
_keyboardConstraint.constant = -_kbHeight-heightOffset;
} else {
_keyboardConstraint.constant = -_kbHeight+10;
if(!SCREEN4ORLOWERLANDSCAPE){
_keyboardConstraint.constant = -_kbHeight-heightOffset+15;
}
}
[self.view layoutIfNeeded];
[_fieldsView updateLayout];
Expand Down