2
0

Fix landscape layout.

[FIXED]     View layout problems while in landscape.

- #MP-8 fixed
This commit is contained in:
Maarten Billemont 2012-03-01 00:04:34 +01:00
parent c508ed8c46
commit ac735f3ccb
2 changed files with 150 additions and 145 deletions

View File

@ -52,6 +52,12 @@
return [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad || interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown; return [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad || interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown;
} }
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[self setHelpHidden:![self isHelpVisible] animated:NO];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"MP_Main_ChooseType"]) if ([[segue identifier] isEqualToString:@"MP_Main_ChooseType"])
@ -183,7 +189,7 @@
- (BOOL)isHelpVisible { - (BOOL)isHelpVisible {
return self.helpContainer.frame.origin.y < 400; return self.helpContainer.frame.origin.y == 216;
} }
- (void)toggleHelpAnimated:(BOOL)animated { - (void)toggleHelpAnimated:(BOOL)animated {
@ -194,10 +200,9 @@
- (void)setHelpHidden:(BOOL)hidden animated:(BOOL)animated { - (void)setHelpHidden:(BOOL)hidden animated:(BOOL)animated {
[UIView animateWithDuration:animated? 0.3f: 0 animations:^{ [UIView animateWithDuration:animated? 0.3f: 0 animations:^{
if (hidden) { if (hidden) {
self.contentContainer.frame = CGRectSetHeight(self.contentContainer.frame, 373); self.contentContainer.frame = CGRectSetHeight(self.contentContainer.frame, self.view.bounds.size.height - 44);
self.helpContainer.frame = CGRectSetY(self.helpContainer.frame, 416); self.helpContainer.frame = CGRectSetY(self.helpContainer.frame, self.view.bounds.size.height);
[MPConfig get].helpHidden = [NSNumber numberWithBool:YES]; [MPConfig get].helpHidden = [NSNumber numberWithBool:YES];
} else { } else {
self.contentContainer.frame = CGRectSetHeight(self.contentContainer.frame, 175); self.contentContainer.frame = CGRectSetHeight(self.contentContainer.frame, 175);
@ -239,7 +244,7 @@
self.contentTipContainer.alpha = 0; self.contentTipContainer.alpha = 0;
} completion:^(BOOL finished) { } completion:^(BOOL finished) {
if (finished) if (finished)
icon.hidden = YES; icon.hidden = YES;
}]; }];
}); });
} }
@ -337,149 +342,149 @@
- (IBAction)action:(id)sender { - (IBAction)action:(id)sender {
[PearlSheet showSheetWithTitle:nil message:nil viewStyle:UIActionSheetStyleAutomatic [PearlSheet showSheetWithTitle:nil message:nil viewStyle:UIActionSheetStyleAutomatic
tappedButtonBlock:^(UIActionSheet *sheet, NSInteger buttonIndex) { tappedButtonBlock:^(UIActionSheet *sheet, NSInteger buttonIndex) {
if (buttonIndex == [sheet cancelButtonIndex]) if (buttonIndex == [sheet cancelButtonIndex])
return; return;
switch (buttonIndex - [sheet firstOtherButtonIndex]) { switch (buttonIndex - [sheet firstOtherButtonIndex]) {
case 0: case 0:
[self toggleHelpAnimated:YES]; [self toggleHelpAnimated:YES];
break; break;
case 1: case 1:
[self setHelpChapter:@"faq"]; [self setHelpChapter:@"faq"];
[self setHelpHidden:NO animated:YES]; [self setHelpHidden:NO animated:YES];
break; break;
case 2: case 2:
[[MPAppDelegate get] showGuide]; [[MPAppDelegate get] showGuide];
break; break;
case 3: { case 3: {
IASKAppSettingsViewController *settingsVC = [IASKAppSettingsViewController new]; IASKAppSettingsViewController *settingsVC = [IASKAppSettingsViewController new];
settingsVC.delegate = self; settingsVC.delegate = self;
[self.navigationController pushViewController:settingsVC animated:YES]; [self.navigationController pushViewController:settingsVC animated:YES];
break; break;
} }
#ifndef PRODUCTION #ifndef PRODUCTION
case 4: case 4:
[TestFlight openFeedbackView]; [TestFlight openFeedbackView];
break; break;
case 5: { case 5: {
#else #else
case 4: { case 4: {
#endif #endif
[[MPAppDelegate get] signOut]; [[MPAppDelegate get] signOut];
break; break;
} }
} }
#ifndef PRODUCTION #ifndef PRODUCTION
[TestFlight passCheckpoint:MPTestFlightCheckpointAction]; [TestFlight passCheckpoint:MPTestFlightCheckpointAction];
#endif #endif
} cancelTitle:[PearlStrings get].commonButtonCancel destructiveTitle:nil } cancelTitle:[PearlStrings get].commonButtonCancel destructiveTitle:nil
otherTitles: otherTitles:
[self isHelpVisible]? @"Hide Help": @"Show Help", @"FAQ", @"Tutorial", @"Settings", [self isHelpVisible]? @"Hide Help": @"Show Help", @"FAQ", @"Tutorial", @"Settings",
#ifndef PRODUCTION #ifndef PRODUCTION
@"Feedback", @"Feedback",
#endif #endif
@"Sign Out", @"Sign Out",
nil]; nil];
} }
- (MPElementType)selectedType { - (MPElementType)selectedType {
return self.activeElement.type; return self.activeElement.type;
} }
- (void)didSelectType:(MPElementType)type { - (void)didSelectType:(MPElementType)type {
[self updateElement:^{ [self updateElement:^{
// Update password type. // Update password type.
if (ClassFromMPElementType(type) != ClassFromMPElementType(self.activeElement.type)) if (ClassFromMPElementType(type) != ClassFromMPElementType(self.activeElement.type))
// Type requires a different class of element. Recreate the element. // Type requires a different class of element. Recreate the element.
[[MPAppDelegate managedObjectContext] performBlockAndWait:^{ [[MPAppDelegate managedObjectContext] performBlockAndWait:^{
MPElementEntity *newElement = [NSEntityDescription insertNewObjectForEntityForName:ClassNameFromMPElementType(type) MPElementEntity *newElement = [NSEntityDescription insertNewObjectForEntityForName:ClassNameFromMPElementType(type)
inManagedObjectContext:[MPAppDelegate managedObjectContext]]; inManagedObjectContext:[MPAppDelegate managedObjectContext]];
newElement.name = self.activeElement.name; newElement.name = self.activeElement.name;
newElement.mpHashHex = self.activeElement.mpHashHex; newElement.mpHashHex = self.activeElement.mpHashHex;
newElement.uses = self.activeElement.uses; newElement.uses = self.activeElement.uses;
newElement.lastUsed = self.activeElement.lastUsed; newElement.lastUsed = self.activeElement.lastUsed;
[[MPAppDelegate managedObjectContext] deleteObject:self.activeElement]; [[MPAppDelegate managedObjectContext] deleteObject:self.activeElement];
self.activeElement = newElement; self.activeElement = newElement;
}]; }];
self.activeElement.type = type; self.activeElement.type = type;
#ifndef PRODUCTION #ifndef PRODUCTION
[TestFlight passCheckpoint:[NSString stringWithFormat:MPTestFlightCheckpointSelectType, NSStringFromMPElementType(type)]]; [TestFlight passCheckpoint:[NSString stringWithFormat:MPTestFlightCheckpointSelectType, NSStringFromMPElementType(type)]];
#endif #endif
if (type & MPElementTypeClassStored && ![self.activeElement.description length]) if (type & MPElementTypeClassStored && ![self.activeElement.description length])
[self showContentTip:@"Tap to set a password." withIcon:self.contentTipEditIcon]; [self showContentTip:@"Tap to set a password." withIcon:self.contentTipEditIcon];
}]; }];
} }
- (void)didSelectElement:(MPElementEntity *)element { - (void)didSelectElement:(MPElementEntity *)element {
if (element) { if (element) {
self.activeElement = element; self.activeElement = element;
[self.activeElement use]; [self.activeElement use];
[self.searchDisplayController setActive:NO animated:YES]; [self.searchDisplayController setActive:NO animated:YES];
self.searchDisplayController.searchBar.text = self.activeElement.name; self.searchDisplayController.searchBar.text = self.activeElement.name;
#ifndef PRODUCTION #ifndef PRODUCTION
[TestFlight passCheckpoint:MPTestFlightCheckpointSelectElement]; [TestFlight passCheckpoint:MPTestFlightCheckpointSelectElement];
#endif #endif
} }
[self updateAnimated:YES]; [self updateAnimated:YES];
} }
- (BOOL)textFieldShouldReturn:(UITextField *)textField { - (BOOL)textFieldShouldReturn:(UITextField *)textField {
if (textField == self.contentField) if (textField == self.contentField)
[self.contentField resignFirstResponder]; [self.contentField resignFirstResponder];
return YES; return YES;
} }
- (void)textFieldDidEndEditing:(UITextField *)textField { - (void)textFieldDidEndEditing:(UITextField *)textField {
if (textField == self.contentField) { if (textField == self.contentField) {
self.contentField.enabled = NO; self.contentField.enabled = NO;
if (![self.activeElement isKindOfClass:[MPElementStoredEntity class]]) if (![self.activeElement isKindOfClass:[MPElementStoredEntity class]])
// Not of a type whose content can be edited. // Not of a type whose content can be edited.
return; return;
if ([((MPElementStoredEntity *) self.activeElement).content isEqual:self.contentField.text]) if ([((MPElementStoredEntity *) self.activeElement).content isEqual:self.contentField.text])
// Content hasn't changed. // Content hasn't changed.
return; return;
[self updateElement:^{ [self updateElement:^{
((MPElementStoredEntity *) self.activeElement).content = self.contentField.text; ((MPElementStoredEntity *) self.activeElement).content = self.contentField.text;
}]; }];
} }
} }
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType { navigationType:(UIWebViewNavigationType)navigationType {
if (navigationType == UIWebViewNavigationTypeLinkClicked) { if (navigationType == UIWebViewNavigationTypeLinkClicked) {
#ifndef PRODUCTION #ifndef PRODUCTION
[TestFlight passCheckpoint:MPTestFlightCheckpointExternalLink]; [TestFlight passCheckpoint:MPTestFlightCheckpointExternalLink];
#endif #endif
[[UIApplication sharedApplication] openURL:[request URL]]; [[UIApplication sharedApplication] openURL:[request URL]];
return NO; return NO;
} }
return YES; return YES;
} }
- (void)settingsViewControllerDidEnd:(IASKAppSettingsViewController *)sender { - (void)settingsViewControllerDidEnd:(IASKAppSettingsViewController *)sender {
while ([self.navigationController.viewControllers containsObject:sender]) while ([self.navigationController.viewControllers containsObject:sender])
[self.navigationController popViewControllerAnimated:YES]; [self.navigationController popViewControllerAnimated:YES];
} }
@end @end

View File

@ -370,7 +370,7 @@ The passwords aren't saved anywhere. This is a major advantage: if you loose yo
</button> </button>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" alpha="0.50000000000000011" contentMode="left" text="apple.com" lineBreakMode="tailTruncation" minimumFontSize="10" id="gSK-aB-wNI"> <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" alpha="0.50000000000000011" contentMode="left" text="apple.com" lineBreakMode="tailTruncation" minimumFontSize="10" id="gSK-aB-wNI">
<rect key="frame" x="25" y="20" width="270" height="26"/> <rect key="frame" x="25" y="20" width="270" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="Copperplate" family="Copperplate" pointSize="12"/> <fontDescription key="fontDescription" name="Copperplate" family="Copperplate" pointSize="12"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
@ -379,7 +379,7 @@ The passwords aren't saved anywhere. This is a major advantage: if you loose yo
</label> </label>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="S3cre7^Pa$swcrD" textAlignment="center" minimumFontSize="17" clearButtonMode="whileEditing" id="fiX-10-fif"> <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="S3cre7^Pa$swcrD" textAlignment="center" minimumFontSize="17" clearButtonMode="whileEditing" id="fiX-10-fif">
<rect key="frame" x="20" y="46" width="280" height="60"/> <rect key="frame" x="20" y="46" width="280" height="60"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<color key="textColor" red="0.47450980390000003" green="0.86666666670000003" blue="0.98431372549999996" alpha="1" colorSpace="calibratedRGB"/> <color key="textColor" red="0.47450980390000003" green="0.86666666670000003" blue="0.98431372549999996" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" name="Copperplate-Bold" family="Copperplate" pointSize="26"/> <fontDescription key="fontDescription" name="Copperplate-Bold" family="Copperplate" pointSize="26"/>
<textInputTraits key="textInputTraits" autocorrectionType="no"/> <textInputTraits key="textInputTraits" autocorrectionType="no"/>
@ -452,16 +452,16 @@ The passwords aren't saved anywhere. This is a major advantage: if you loose yo
<rect key="frame" x="0.0" y="0.0" width="210" height="60"/> <rect key="frame" x="0.0" y="0.0" width="210" height="60"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</imageView> </imageView>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Tap to set a password." textAlignment="center" lineBreakMode="tailTruncation" minimumFontSize="10" id="ieN-QQ-PyR"> <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Tap to set a password." textAlignment="center" lineBreakMode="tailTruncation" minimumFontSize="10" id="ieN-QQ-PyR">
<rect key="frame" x="20" y="0.0" width="170" height="40"/> <rect key="frame" x="20" y="0.0" width="171" height="40"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/> <fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/> <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" image="icon_edit.png" id="KEn-n3-qhX"> <imageView userInteractionEnabled="NO" contentMode="scaleToFill" image="icon_edit.png" id="KEn-n3-qhX">
<rect key="frame" x="48" y="6" width="24" height="24"/> <rect key="frame" x="48" y="8" width="24" height="24"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
</imageView> </imageView>
</subviews> </subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>