From 0760b9cd14b404478695bde1accb1234f46ca44c Mon Sep 17 00:00:00 2001 From: Craig Earley Date: Fri, 3 Aug 2012 10:38:10 -0400 Subject: [PATCH 1/4] Fixed problem causing crash when QPickerElement items have spaces. --- quickdialog/QPickerWhitespaceDelimitedStringParser.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quickdialog/QPickerWhitespaceDelimitedStringParser.m b/quickdialog/QPickerWhitespaceDelimitedStringParser.m index 30fadaec..644d84e3 100644 --- a/quickdialog/QPickerWhitespaceDelimitedStringParser.m +++ b/quickdialog/QPickerWhitespaceDelimitedStringParser.m @@ -12,13 +12,13 @@ @implementation QPickerWhitespaceDelimitedStringParser - (id)objectFromComponentsValues:(NSArray *)componentsValues { - return [componentsValues componentsJoinedByString:@" "]; + return [componentsValues componentsJoinedByString:@"\t"]; } - (NSArray *)componentsValuesFromObject:(id)object { NSString *stringValue = [object isKindOfClass:[NSString class]] ? object : [object description]; - return [stringValue componentsSeparatedByString:@" "]; + return [stringValue componentsSeparatedByString:@"\t"]; } @end From 7e97842f5dbb1132bd04272028c2f967e91950ef Mon Sep 17 00:00:00 2001 From: HiveHicks Date: Tue, 26 Jun 2012 18:40:01 +0400 Subject: [PATCH 2/4] Prev/Next navigation fix so that we could "jump over", for instance, QRadioElement, that is also a QEntryElement, but is not focusable --- quickdialog/QEntryElement.h | 4 +++- quickdialog/QEntryElement.m | 3 +++ quickdialog/QEntryTableViewCell.m | 10 ++++++---- quickdialog/QMultilineElement.m | 3 +++ quickdialog/QRadioElement.m | 3 +++ quickdialog/QSegmentedElement.m | 4 ++++ 6 files changed, 22 insertions(+), 5 deletions(-) diff --git a/quickdialog/QEntryElement.h b/quickdialog/QEntryElement.h index 338a9925..4f177bcf 100644 --- a/quickdialog/QEntryElement.h +++ b/quickdialog/QEntryElement.h @@ -43,6 +43,8 @@ - (QEntryElement *)init; - - (QEntryElement *)initWithTitle:(NSString *)string Value:(NSString *)param Placeholder:(NSString *)string1; + +- (BOOL)canTakeFocus; + @end \ No newline at end of file diff --git a/quickdialog/QEntryElement.m b/quickdialog/QEntryElement.m index 624e7a40..e9c28369 100644 --- a/quickdialog/QEntryElement.m +++ b/quickdialog/QEntryElement.m @@ -72,6 +72,9 @@ - (void)fetchValueIntoObject:(id)obj { [obj setValue:_textValue forKey:_key]; } +- (BOOL)canTakeFocus { + return YES; +} #pragma mark - UITextInputTraits diff --git a/quickdialog/QEntryTableViewCell.m b/quickdialog/QEntryTableViewCell.m index 39b75c8f..3f768695 100644 --- a/quickdialog/QEntryTableViewCell.m +++ b/quickdialog/QEntryTableViewCell.m @@ -260,13 +260,14 @@ - (BOOL)resignFirstResponder { } - (QEntryElement *)findPreviousElementToFocusOn { + QEntryElement *previousElement = nil; for (QSection *section in _entryElement.parentSection.rootElement.sections) { - for (QElement * e in section.elements){ + for (QElement *e in section.elements) { if (e == _entryElement) { return previousElement; } - else if ([e isKindOfClass:[QEntryElement class]]){ + else if ([e isKindOfClass:[QEntryElement class]] && [(QEntryElement *)e canTakeFocus]) { previousElement = (QEntryElement *)e; } } @@ -275,13 +276,14 @@ - (QEntryElement *)findPreviousElementToFocusOn { } - (QEntryElement *)findNextElementToFocusOn { + BOOL foundSelf = NO; for (QSection *section in _entryElement.parentSection.rootElement.sections) { - for (QElement * e in section.elements){ + for (QElement *e in section.elements) { if (e == _entryElement) { foundSelf = YES; } - else if (foundSelf && [e isKindOfClass:[QEntryElement class]]){ + else if (foundSelf && [e isKindOfClass:[QEntryElement class]] && [(QEntryElement *)e canTakeFocus]) { return (QEntryElement *) e; } } diff --git a/quickdialog/QMultilineElement.m b/quickdialog/QMultilineElement.m index 4ec90119..0f4444e0 100644 --- a/quickdialog/QMultilineElement.m +++ b/quickdialog/QMultilineElement.m @@ -65,5 +65,8 @@ - (void)fetchValueIntoObject:(id)obj [obj setValue:self.textValue forKey:_key]; } +- (BOOL)canTakeFocus { + return NO; +} @end diff --git a/quickdialog/QRadioElement.m b/quickdialog/QRadioElement.m index 8c0ddf8f..87511056 100644 --- a/quickdialog/QRadioElement.m +++ b/quickdialog/QRadioElement.m @@ -140,5 +140,8 @@ - (void)fetchValueIntoObject:(id)obj { } } +- (BOOL)canTakeFocus { + return NO; +} @end diff --git a/quickdialog/QSegmentedElement.m b/quickdialog/QSegmentedElement.m index 7eca63fb..7440cfa0 100644 --- a/quickdialog/QSegmentedElement.m +++ b/quickdialog/QSegmentedElement.m @@ -50,4 +50,8 @@ - (UITableViewCell *)getCellForTableView:(QuickDialogTableView *)tableView contr return cell; } +- (BOOL)canTakeFocus { + return NO; +} + @end \ No newline at end of file From abcd4c2ea7394b0f69194ffe9d89d2eb432c4af5 Mon Sep 17 00:00:00 2001 From: HiveHicks Date: Tue, 26 Jun 2012 19:32:40 +0400 Subject: [PATCH 3/4] Fixes issue #102 --- quickdialog/QEntryTableViewCell.m | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/quickdialog/QEntryTableViewCell.m b/quickdialog/QEntryTableViewCell.m index 3f768695..9fcf6051 100644 --- a/quickdialog/QEntryTableViewCell.m +++ b/quickdialog/QEntryTableViewCell.m @@ -212,23 +212,33 @@ - (BOOL)textFieldShouldReturn:(UITextField *)textField { return YES; } -- (void) handleActionBarPreviousNext:(UISegmentedControl *)control { +- (void)handleActionBarPreviousNext:(UISegmentedControl *)control { + QEntryElement *element; + const BOOL isNext = control.selectedSegmentIndex == 1; - if (isNext){ + if (isNext) { element = [self findNextElementToFocusOn]; } else { element = [self findPreviousElementToFocusOn]; } - if (element!=nil){ + + if (element != nil) { + UITableViewCell *cell = [_quickformTableView cellForElement:element]; - if (cell!=nil){ + if (cell != nil) { [cell becomeFirstResponder]; - } else { - dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 50 * USEC_PER_SEC); - dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ + } + else { + + [_quickformTableView scrollToRowAtIndexPath:[_quickformTableView indexForElement:element] + atScrollPosition:UITableViewScrollPositionMiddle + animated:YES]; + + dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 0.3 * NSEC_PER_SEC); + dispatch_after(popTime, dispatch_get_main_queue(), ^{ UITableViewCell *c = [_quickformTableView cellForElement:element]; - if (c!=nil){ + if (c != nil) { [c becomeFirstResponder]; } }); From ac96b2d918f172ba3579a219b71adf0e9465e806 Mon Sep 17 00:00:00 2001 From: Craig Earley Date: Fri, 3 Aug 2012 10:38:10 -0400 Subject: [PATCH 4/4] Fixed problem causing crash when QPickerElement items have spaces. --- QuickDialog.xcodeproj/project.pbxproj | 16 ++++++++-------- quickdialog/QPickerElement.m | 6 +++--- ...arser.h => QPickerTabDelimitedStringParser.h} | 4 ++-- ...arser.m => QPickerTabDelimitedStringParser.m} | 10 +++++----- 4 files changed, 18 insertions(+), 18 deletions(-) rename quickdialog/{QPickerWhitespaceDelimitedStringParser.h => QPickerTabDelimitedStringParser.h} (51%) rename quickdialog/{QPickerWhitespaceDelimitedStringParser.m => QPickerTabDelimitedStringParser.m} (56%) diff --git a/QuickDialog.xcodeproj/project.pbxproj b/QuickDialog.xcodeproj/project.pbxproj index 762611d4..0b83616c 100644 --- a/QuickDialog.xcodeproj/project.pbxproj +++ b/QuickDialog.xcodeproj/project.pbxproj @@ -153,8 +153,8 @@ F2F23A22152DD48B00EB6685 /* QPickerTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = F2F23A1B152DD48B00EB6685 /* QPickerTableViewCell.h */; }; F2F23A23152DD48B00EB6685 /* QPickerTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F2F23A1C152DD48B00EB6685 /* QPickerTableViewCell.m */; }; F2F23A24152DD48B00EB6685 /* QPickerValueParser.h in Headers */ = {isa = PBXBuildFile; fileRef = F2F23A1D152DD48B00EB6685 /* QPickerValueParser.h */; }; - F2F23A25152DD48B00EB6685 /* QPickerWhitespaceDelimitedStringParser.h in Headers */ = {isa = PBXBuildFile; fileRef = F2F23A1E152DD48B00EB6685 /* QPickerWhitespaceDelimitedStringParser.h */; }; - F2F23A26152DD48B00EB6685 /* QPickerWhitespaceDelimitedStringParser.m in Sources */ = {isa = PBXBuildFile; fileRef = F2F23A1F152DD48B00EB6685 /* QPickerWhitespaceDelimitedStringParser.m */; }; + F2F23A25152DD48B00EB6685 /* QPickerTabDelimitedStringParser.h in Headers */ = {isa = PBXBuildFile; fileRef = F2F23A1E152DD48B00EB6685 /* QPickerTabDelimitedStringParser.h */; }; + F2F23A26152DD48B00EB6685 /* QPickerTabDelimitedStringParser.m in Sources */ = {isa = PBXBuildFile; fileRef = F2F23A1F152DD48B00EB6685 /* QPickerTabDelimitedStringParser.m */; }; F2F23A26152DD48B00EB6687 /* QuickDialogController+Helpers.m in Sources */ = {isa = PBXBuildFile; fileRef = F2F23A26152DD48B00EB6686 /* QuickDialogController+Helpers.m */; }; F2F23A26152DD48B00EB6689 /* QuickDialogController+Helpers.h in Headers */ = {isa = PBXBuildFile; fileRef = F2F23A26152DD48B00EB6688 /* QuickDialogController+Helpers.h */; }; /* End PBXBuildFile section */ @@ -331,8 +331,8 @@ F2F23A1B152DD48B00EB6685 /* QPickerTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = QPickerTableViewCell.h; path = quickdialog/QPickerTableViewCell.h; sourceTree = SOURCE_ROOT; }; F2F23A1C152DD48B00EB6685 /* QPickerTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = QPickerTableViewCell.m; path = quickdialog/QPickerTableViewCell.m; sourceTree = SOURCE_ROOT; }; F2F23A1D152DD48B00EB6685 /* QPickerValueParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = QPickerValueParser.h; path = quickdialog/QPickerValueParser.h; sourceTree = SOURCE_ROOT; }; - F2F23A1E152DD48B00EB6685 /* QPickerWhitespaceDelimitedStringParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = QPickerWhitespaceDelimitedStringParser.h; path = quickdialog/QPickerWhitespaceDelimitedStringParser.h; sourceTree = SOURCE_ROOT; }; - F2F23A1F152DD48B00EB6685 /* QPickerWhitespaceDelimitedStringParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = QPickerWhitespaceDelimitedStringParser.m; path = quickdialog/QPickerWhitespaceDelimitedStringParser.m; sourceTree = SOURCE_ROOT; }; + F2F23A1E152DD48B00EB6685 /* QPickerTabDelimitedStringParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = QPickerTabDelimitedStringParser.h; path = quickdialog/QPickerTabDelimitedStringParser.h; sourceTree = SOURCE_ROOT; }; + F2F23A1F152DD48B00EB6685 /* QPickerTabDelimitedStringParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = QPickerTabDelimitedStringParser.m; path = quickdialog/QPickerTabDelimitedStringParser.m; sourceTree = SOURCE_ROOT; }; F2F23A26152DD48B00EB6686 /* QuickDialogController+Helpers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "QuickDialogController+Helpers.m"; path = "quickdialog/QuickDialogController+Helpers.m"; sourceTree = SOURCE_ROOT; }; F2F23A26152DD48B00EB6688 /* QuickDialogController+Helpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "QuickDialogController+Helpers.h"; path = "quickdialog/QuickDialogController+Helpers.h"; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ @@ -612,8 +612,8 @@ F2F23A1B152DD48B00EB6685 /* QPickerTableViewCell.h */, F2F23A1C152DD48B00EB6685 /* QPickerTableViewCell.m */, F2F23A1D152DD48B00EB6685 /* QPickerValueParser.h */, - F2F23A1E152DD48B00EB6685 /* QPickerWhitespaceDelimitedStringParser.h */, - F2F23A1F152DD48B00EB6685 /* QPickerWhitespaceDelimitedStringParser.m */, + F2F23A1E152DD48B00EB6685 /* QPickerTabDelimitedStringParser.h */, + F2F23A1F152DD48B00EB6685 /* QPickerTabDelimitedStringParser.m */, ); name = QPickerElement; sourceTree = ""; @@ -680,7 +680,7 @@ F2F23A20152DD48B00EB6685 /* QPickerElement.h in Headers */, F2F23A22152DD48B00EB6685 /* QPickerTableViewCell.h in Headers */, F2F23A24152DD48B00EB6685 /* QPickerValueParser.h in Headers */, - F2F23A25152DD48B00EB6685 /* QPickerWhitespaceDelimitedStringParser.h in Headers */, + F2F23A25152DD48B00EB6685 /* QPickerTabDelimitedStringParser.h in Headers */, F2F23A26152DD48B00EB6689 /* QuickDialogController+Helpers.h in Headers */, D894F38A15559D34000E3C0F /* NSMutableArray+IMSExtensions.h in Headers */, F2304357156CDFDD006D0A56 /* QTextField.h in Headers */, @@ -837,7 +837,7 @@ F2E614A3151CA1A100F36976 /* QSelectItemElement.m in Sources */, F2F23A21152DD48B00EB6685 /* QPickerElement.m in Sources */, F2F23A23152DD48B00EB6685 /* QPickerTableViewCell.m in Sources */, - F2F23A26152DD48B00EB6685 /* QPickerWhitespaceDelimitedStringParser.m in Sources */, + F2F23A26152DD48B00EB6685 /* QPickerTabDelimitedStringParser.m in Sources */, F2F23A26152DD48B00EB6687 /* QuickDialogController+Helpers.m in Sources */, D894F38B15559D34000E3C0F /* NSMutableArray+IMSExtensions.m in Sources */, F2304358156CDFDD006D0A56 /* QTextField.m in Sources */, diff --git a/quickdialog/QPickerElement.m b/quickdialog/QPickerElement.m index f8b9833c..64f56898 100644 --- a/quickdialog/QPickerElement.m +++ b/quickdialog/QPickerElement.m @@ -1,6 +1,6 @@ #import "QPickerElement.h" #import "QPickerTableViewCell.h" -#import "QPickerWhitespaceDelimitedStringParser.h" +#import "QPickerTabDelimitedStringParser.h" @implementation QPickerElement { @@ -18,7 +18,7 @@ @implementation QPickerElement - (QPickerElement *)init { if (self = [super init]) { - self.valueParser = [QPickerWhitespaceDelimitedStringParser new]; + self.valueParser = [QPickerTabDelimitedStringParser new]; } return self; } @@ -27,7 +27,7 @@ - (QPickerElement *)initWithTitle:(NSString *)title items:(NSArray *)items value { if ((self = [super initWithTitle:title Value:value])) { _items = items; - self.valueParser = [QPickerWhitespaceDelimitedStringParser new]; + self.valueParser = [QPickerTabDelimitedStringParser new]; } return self; } diff --git a/quickdialog/QPickerWhitespaceDelimitedStringParser.h b/quickdialog/QPickerTabDelimitedStringParser.h similarity index 51% rename from quickdialog/QPickerWhitespaceDelimitedStringParser.h rename to quickdialog/QPickerTabDelimitedStringParser.h index ad3b67d0..7559fa05 100644 --- a/quickdialog/QPickerWhitespaceDelimitedStringParser.h +++ b/quickdialog/QPickerTabDelimitedStringParser.h @@ -1,5 +1,5 @@ // -// QPickerWhitespaceDelimitedStringParser.h +// QPickerTabDelimitedStringParser.h // QuickDialog // // Created by HiveHicks on 05.04.12. @@ -8,6 +8,6 @@ #import #import "QPickerValueParser.h" -@interface QPickerWhitespaceDelimitedStringParser : NSObject +@interface QPickerTabDelimitedStringParser : NSObject @end diff --git a/quickdialog/QPickerWhitespaceDelimitedStringParser.m b/quickdialog/QPickerTabDelimitedStringParser.m similarity index 56% rename from quickdialog/QPickerWhitespaceDelimitedStringParser.m rename to quickdialog/QPickerTabDelimitedStringParser.m index 30fadaec..031faf91 100644 --- a/quickdialog/QPickerWhitespaceDelimitedStringParser.m +++ b/quickdialog/QPickerTabDelimitedStringParser.m @@ -1,24 +1,24 @@ // -// QPickerWhitespaceDelimitedStringParser.m +// QPickerTabDelimitedStringParser.m // QuickDialog // // Created by HiveHicks on 05.04.12. // Copyright (c) 2012 __MyCompanyName__. All rights reserved. // -#import "QPickerWhitespaceDelimitedStringParser.h" +#import "QPickerTabDelimitedStringParser.h" -@implementation QPickerWhitespaceDelimitedStringParser +@implementation QPickerTabDelimitedStringParser - (id)objectFromComponentsValues:(NSArray *)componentsValues { - return [componentsValues componentsJoinedByString:@" "]; + return [componentsValues componentsJoinedByString:@"\t"]; } - (NSArray *)componentsValuesFromObject:(id)object { NSString *stringValue = [object isKindOfClass:[NSString class]] ? object : [object description]; - return [stringValue componentsSeparatedByString:@" "]; + return [stringValue componentsSeparatedByString:@"\t"]; } @end