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

Commit

Permalink
TWEAK: showing description on forms for all but one device/orientatio…
Browse files Browse the repository at this point in the history
…n (4s)
  • Loading branch information
Anna Billstrom committed Nov 10, 2015
1 parent 25808dc commit 82e393e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
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

0 comments on commit 82e393e

Please sign in to comment.