From ce9290a27797f672faecce273fd7c555692dd0ca Mon Sep 17 00:00:00 2001 From: Kilian Hofmann Date: Mon, 21 Mar 2016 22:49:05 +0100 Subject: [PATCH] Better view with independent labels and LSK for use without NSAttributedString. Dynamical adjustment for screen height. --- .../xcdebugger/Breakpoints_v2.xcbkptlist | 50 ++ FMC Planner 2/Base.lproj/Main.storyboard | 727 +++++++++--------- FMC Planner 2/ViewControllerScreen.h | 3 + FMC Planner 2/ViewControllerScreen.m | 65 +- 4 files changed, 444 insertions(+), 401 deletions(-) diff --git a/FMC Planner 2.xcodeproj/xcuserdata/Kili2.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/FMC Planner 2.xcodeproj/xcuserdata/Kili2.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index fe2b454..a34e52e 100644 --- a/FMC Planner 2.xcodeproj/xcuserdata/Kili2.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/FMC Planner 2.xcodeproj/xcuserdata/Kili2.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -2,4 +2,54 @@ + + + + + + + + + + + + + + diff --git a/FMC Planner 2/Base.lproj/Main.storyboard b/FMC Planner 2/Base.lproj/Main.storyboard index 6c559ce..d895c95 100644 --- a/FMC Planner 2/Base.lproj/Main.storyboard +++ b/FMC Planner 2/Base.lproj/Main.storyboard @@ -3,7 +3,7 @@ - + @@ -18,12 +18,6 @@ - - - - - - @@ -34,357 +28,31 @@ + + + + + + - + + - + - - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -774,9 +442,370 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - diff --git a/FMC Planner 2/ViewControllerScreen.h b/FMC Planner 2/ViewControllerScreen.h index c6ecd07..65edd1d 100644 --- a/FMC Planner 2/ViewControllerScreen.h +++ b/FMC Planner 2/ViewControllerScreen.h @@ -12,6 +12,7 @@ @interface ViewControllerScreen : UIViewController @property(strong, nonatomic) IBOutletCollection(UILabel) NSArray *LSK; +@property(strong, nonatomic) IBOutletCollection(UILabel) NSArray *Desc; @property(strong, nonatomic) IBOutlet UILabel *Scratchpad; @@ -19,6 +20,8 @@ @property(strong, nonatomic) ViewController *main; +@property(strong, nonatomic) IBOutlet NSLayoutConstraint *FrameHeight; + - (void)loadScreen:(NSString *)screenName; @end diff --git a/FMC Planner 2/ViewControllerScreen.m b/FMC Planner 2/ViewControllerScreen.m index 3036f15..53712f4 100644 --- a/FMC Planner 2/ViewControllerScreen.m +++ b/FMC Planner 2/ViewControllerScreen.m @@ -37,15 +37,22 @@ } - (void)viewDidLayoutSubviews { + _FrameHeight.constant = self.view.frame.size.height / 14.5; // Size and LineBreak + _Header.font = [self findAdaptiveFontForUILabelSize:_Header.frame.size withMinimumSize:5 - withMod:1]; + withMod:0.7]; _Header.adjustsFontSizeToFitWidth = YES; _Scratchpad.font = [self findAdaptiveFontForUILabelSize:_Scratchpad.frame.size withMinimumSize:5 - withMod:1]; + withMod:0.7]; _Scratchpad.adjustsFontSizeToFitWidth = YES; + for (UILabel *label in _LSK) { + label.font = [self findAdaptiveFontForUILabelSize:_Header.frame.size + withMinimumSize:5 + withMod:0.6]; + } } - (void)clearScreen { @@ -57,47 +64,10 @@ } - (void)enterLSK:(UITapGestureRecognizer *)tapReg { - UILabel *label = ((UILabel *)tapReg.view); - BOOL append = false; - NSMutableAttributedString *attSOld = [label.attributedText mutableCopy]; - NSRange rangeDesc = [[attSOld string] - rangeOfString:[[[attSOld string] componentsSeparatedByString:@"\n"] - firstObject]]; - NSRange rangeEntry = [[attSOld string] - rangeOfString:[[[attSOld string] componentsSeparatedByString:@"\n"] - lastObject]]; - append = rangeDesc.length + 1 == attSOld.length; - if ([_Scratchpad.text isEqualToString:@"DELETE"]) { - if (append) { - } else { - NSRange new = NSMakeRange(rangeDesc.length + 1, rangeEntry.length); - [attSOld replaceCharactersInRange:new withString:@""]; - label.attributedText = attSOld; - } + ((UILabel *)tapReg.view).text = @""; } else { - if (!append) { - [attSOld replaceCharactersInRange:NSMakeRange(rangeDesc.length + 1, - rangeEntry.length) - withString:_Scratchpad.text]; - [attSOld - addAttribute:NSFontAttributeName - value:[self findAdaptiveFontForUILabelSize:label.frame.size - withMinimumSize:5 - withMod:2] - range:NSMakeRange(rangeDesc.length + 1, rangeEntry.length)]; - } else { - NSMutableAttributedString *attSNew = - [[NSMutableAttributedString alloc] initWithString:_Scratchpad.text]; - [attSNew - addAttribute:NSFontAttributeName - value:[self findAdaptiveFontForUILabelSize:label.frame.size - withMinimumSize:5 - withMod:2] - range:NSMakeRange(0, attSNew.length)]; - [attSOld appendAttributedString:attSNew]; - } - label.attributedText = attSOld; + ((UILabel *)tapReg.view).text = _Scratchpad.text; } _Scratchpad.text = @""; } @@ -150,17 +120,8 @@ NSArray *screen = [[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:screenName ofType:@"plist"]]; - for (int i = 0; i < _LSK.count; i++) { - NSMutableAttributedString *attS = [[NSMutableAttributedString alloc] - initWithString:[NSString stringWithFormat:@"%@\n", screen[i]]]; - NSRange range = [[attS string] rangeOfString:screen[i]]; - [attS addAttribute:NSFontAttributeName - value:[self findAdaptiveFontForUILabelSize:((UILabel *)_LSK[i]) - .frame.size - withMinimumSize:5 - withMod:2.5] - range:range]; - ((UILabel *)_LSK[i]).attributedText = attS; + for (int i = 0; i < _Desc.count; i++) { + ((UILabel *)_Desc[i]).text = [NSString stringWithFormat:@"%@\n", screen[i]]; } }