diff --git a/MYSForms/MYSForms/MYSFormButton.m b/MYSForms/MYSForms/MYSFormButton.m index c3dd32e..22689f0 100644 --- a/MYSForms/MYSForms/MYSFormButton.m +++ b/MYSForms/MYSForms/MYSFormButton.m @@ -83,5 +83,3 @@ - (void)layoutSubviews } @end - - diff --git a/MYSForms/MYSForms/MYSFormButtonCell.m b/MYSForms/MYSForms/MYSFormButtonCell.m index cf09545..d4c8672 100644 --- a/MYSForms/MYSForms/MYSFormButtonCell.m +++ b/MYSForms/MYSForms/MYSFormButtonCell.m @@ -26,7 +26,7 @@ - (void)populateWithElement:(MYSFormButtonElement *)element for (MYSFormButton *button in self.buttons) { [button removeFromSuperview]; - if ([[button actionsForTarget:self forControlEvent:UIControlEventTouchUpInside] count] == 0) { + if (![[button actionsForTarget:self forControlEvent:UIControlEventTouchUpInside] count] == 0) { [button removeTarget:self action:@selector(buttonWasTapped:) forControlEvents:UIControlEventTouchUpInside]; } } diff --git a/MYSForms/MYSForms/MYSFormCell.h b/MYSForms/MYSForms/MYSFormCell.h index 9961bcf..27b25e4 100644 --- a/MYSForms/MYSForms/MYSFormCell.h +++ b/MYSForms/MYSForms/MYSFormCell.h @@ -22,6 +22,6 @@ - (UIView *)textInput; -- (void)didChangeValueAtValueKeyPath; +- (void)modelValueDidChange; @end diff --git a/MYSForms/MYSForms/MYSFormCell.m b/MYSForms/MYSForms/MYSFormCell.m index 5c5d10e..3653920 100644 --- a/MYSForms/MYSForms/MYSFormCell.m +++ b/MYSForms/MYSForms/MYSFormCell.m @@ -41,7 +41,7 @@ - (UIView *)textInput return nil; } -- (void)didChangeValueAtValueKeyPath +- (void)modelValueDidChange { } diff --git a/MYSForms/MYSForms/MYSFormDatePickerCell.m b/MYSForms/MYSForms/MYSFormDatePickerCell.m index 5563889..f59eccb 100644 --- a/MYSForms/MYSForms/MYSFormDatePickerCell.m +++ b/MYSForms/MYSForms/MYSFormDatePickerCell.m @@ -58,7 +58,7 @@ - (NSString *)valueKeyPath return @"selectedDate"; } -- (void)didChangeValueAtValueKeyPath +- (void)modelValueDidChange { if (!self.dateFormatter) { self.dateFormatter = [NSDateFormatter new]; diff --git a/MYSForms/MYSForms/MYSFormDatePickerElement.m b/MYSForms/MYSForms/MYSFormDatePickerElement.m index 0c35614..c1f002f 100644 --- a/MYSForms/MYSForms/MYSFormDatePickerElement.m +++ b/MYSForms/MYSForms/MYSFormDatePickerElement.m @@ -55,11 +55,6 @@ - (BOOL)isEditable return YES; } -- (void)beginEditing -{ - [self.delegate formElementDidRequestResignationOfFirstResponder:self]; -} - #pragma mark - Actions diff --git a/MYSForms/MYSForms/MYSFormElement.h b/MYSForms/MYSForms/MYSFormElement.h index b0407b9..27b0709 100644 --- a/MYSForms/MYSForms/MYSFormElement.h +++ b/MYSForms/MYSForms/MYSFormElement.h @@ -103,11 +103,6 @@ */ - (void)configureCellBlock:(void (^)(id))block; -/** - Returns YES if this is the type of form element that accepts text input. - */ -- (BOOL)isTextInput; - /** Returns YES if the element has a value that can be edited. */ @@ -153,8 +148,6 @@ - (void)formElement:(MYSFormElement *)formElement valueDidChange:(id)value; -- (void)formElementNeedsLayout:(MYSFormElement *)formElement; - - (void)formElement:(MYSFormElement *)formElement didRequestPresentationOfActionSheet:(UIActionSheet *)actionSheet; - (void)formElement:(MYSFormElement *)formElement didRequestPresentationOfViewController:(UIViewController *)viewController @@ -165,8 +158,6 @@ - (void)formElement:(MYSFormElement *)formElement didRequestDismissalOfChildView:(UIView *)childView; -- (void)formElementDidRequestResignationOfFirstResponder:(MYSFormElement *)formElement; - - (void)formElement:(MYSFormElement *)formElement didRequestPushOfViewController:(UIViewController *)viewController; - (MYSFormTheme *)formElementFormTheme; diff --git a/MYSForms/MYSForms/MYSFormElement.m b/MYSForms/MYSForms/MYSFormElement.m index d2828a7..43c976e 100644 --- a/MYSForms/MYSForms/MYSFormElement.m +++ b/MYSForms/MYSForms/MYSFormElement.m @@ -93,7 +93,7 @@ - (void)updateCell if ([self isModelKeyPathValid]) { id modelValue = [self transformedModelValue]; [self.cell setValue:modelValue forKeyPath:[self.cell valueKeyPath]]; - [self.cell didChangeValueAtValueKeyPath]; + [self.cell modelValueDidChange]; } } @@ -102,11 +102,6 @@ - (void)configureCellBlock:(void (^)(id))block self.cellConfigurationBlock = block; } -- (BOOL)isTextInput -{ - return NO; -} - - (BOOL)isEditable { return NO; diff --git a/MYSForms/MYSForms/MYSFormImagePickerCell.m b/MYSForms/MYSForms/MYSFormImagePickerCell.m index 6d66a22..314760c 100644 --- a/MYSForms/MYSForms/MYSFormImagePickerCell.m +++ b/MYSForms/MYSForms/MYSFormImagePickerCell.m @@ -38,7 +38,7 @@ + (CGSize)sizeRequiredForElement:(MYSFormImagePickerElement *)element width:(CGF return CGSizeMake(width, insets.top + 100 + insets.bottom); } -- (void)didChangeValueAtValueKeyPath +- (void)modelValueDidChange { if (!self.imageView.image) { self.imageView.image = self.placeholderImage; diff --git a/MYSForms/MYSForms/MYSFormPickerCell.m b/MYSForms/MYSForms/MYSFormPickerCell.m index a0bee5b..4a1bd21 100644 --- a/MYSForms/MYSForms/MYSFormPickerCell.m +++ b/MYSForms/MYSForms/MYSFormPickerCell.m @@ -38,7 +38,7 @@ - (NSString *)valueKeyPath return @"selectedValue"; } -- (void)didChangeValueAtValueKeyPath +- (void)modelValueDidChange { [self.button setTitle:self.selectedValue forState:UIControlStateNormal]; } diff --git a/MYSForms/MYSForms/MYSFormPickerElement.m b/MYSForms/MYSForms/MYSFormPickerElement.m index 2fc91e9..a44c07f 100644 --- a/MYSForms/MYSForms/MYSFormPickerElement.m +++ b/MYSForms/MYSForms/MYSFormPickerElement.m @@ -67,11 +67,6 @@ - (BOOL)isEditable return YES; } -- (void)beginEditing -{ - [self.delegate formElementDidRequestResignationOfFirstResponder:self]; -} - - (void)setValues:(NSArray *)values { self.data = [values mutableCopy]; diff --git a/MYSForms/MYSForms/MYSFormTextFieldCell.m b/MYSForms/MYSForms/MYSFormTextFieldCell.m index bbf2e43..b78451c 100644 --- a/MYSForms/MYSForms/MYSFormTextFieldCell.m +++ b/MYSForms/MYSForms/MYSFormTextFieldCell.m @@ -82,7 +82,7 @@ - (UIView *)textInput return self.textField; } -- (void)didChangeValueAtValueKeyPath +- (void)modelValueDidChange { if (self.window) { [self layoutLabelAndTextFieldWithText:self.textField.text]; diff --git a/MYSForms/MYSForms/MYSFormTextViewElement.m b/MYSForms/MYSForms/MYSFormTextViewElement.m index 4928200..ea48ac8 100644 --- a/MYSForms/MYSForms/MYSFormTextViewElement.m +++ b/MYSForms/MYSForms/MYSFormTextViewElement.m @@ -44,8 +44,6 @@ - (void)beginEditing } - - #pragma mark - DELEGATE text view cell - (void)textViewFormCell:(MYSFormTextViewCell *)cell textDidChange:(NSString *)text @@ -53,10 +51,5 @@ - (void)textViewFormCell:(MYSFormTextViewCell *)cell textDidChange:(NSString *)t [self.delegate formElement:self valueDidChange:text]; } -- (NSString *)textViewFormCellCurrentModelValue:(MYSFormTextViewCell *)cell -{ - return [self.dataSource modelValueForFormElement:self]; -} - @end diff --git a/MYSForms/MYSForms/MYSFormToggleElement.m b/MYSForms/MYSForms/MYSFormToggleElement.m index 0a8e00e..b60f344 100644 --- a/MYSForms/MYSForms/MYSFormToggleElement.m +++ b/MYSForms/MYSForms/MYSFormToggleElement.m @@ -35,11 +35,6 @@ - (BOOL)isEditable return YES; } -- (void)beginEditing -{ - [self.delegate formElementDidRequestResignationOfFirstResponder:self]; -} - #pragma mark - DELEGATE toggle cell diff --git a/MYSForms/MYSForms/MYSFormViewController.m b/MYSForms/MYSForms/MYSFormViewController.m index a9b9f50..92d88a3 100644 --- a/MYSForms/MYSForms/MYSFormViewController.m +++ b/MYSForms/MYSForms/MYSFormViewController.m @@ -129,20 +129,6 @@ - (void)configureForm // overriden by subclasses } -- (void)registerElementCellsForReuse -{ - for (MYSFormElement *element in self.elements) { - [self registerCellForClass:[element cellClass]]; - } - - // register metadata cells - [self registerCellForClass:[MYSFormMessageChildCell class]]; - [self registerCellForClass:[MYSFormLoadingChildCell class]]; - - // register view child cell - [self.collectionView registerClass:[MYSFormViewChildCell class] forCellWithReuseIdentifier:NSStringFromClass([MYSFormViewChildCell class])]; -} - - (void)addFormElement:(MYSFormElement *)element { [self addFormElement:element atIndex:[self.elements count]]; @@ -273,7 +259,7 @@ - (void)showView:(UIView *)view - (void)hideViewRelativeToElement:(MYSFormElement *)element completion:(void (^)(void))completion { - [self hideChildrenOfElements:@[element] type:MYSFormChildElementTypeView completion:nil]; + [self hideChildrenOfElements:@[element] type:MYSFormChildElementTypeView completion:completion]; } @@ -425,11 +411,6 @@ - (void)formElement:(MYSFormElement *)formElement didRequestDismissalOfChildView [self hideChildrenOfElements:@[formElement] type:MYSFormChildElementTypeView completion:nil]; } -- (void)formElementDidRequestResignationOfFirstResponder:(MYSFormElement *)formElement -{ - [self attemptToDismissKeyboard]; -} - - (void)formElement:(MYSFormElement *)formElement didRequestPushOfViewController:(UIViewController *)viewController { [self.navigationController pushViewController:viewController animated:YES]; @@ -645,6 +626,7 @@ - (void)setupKeyboardNotifications if (element) { MYSFormElement *nextElement = [self elementAfter:element]; if (nextElement) { + [self attemptToDismissKeyboard]; [nextElement beginEditing]; } else { @@ -727,6 +709,20 @@ - (void)registerCellForClass:(Class)cellClass [self.collectionView registerNib:nib forCellWithReuseIdentifier:NSStringFromClass(cellClass)]; } +- (void)registerElementCellsForReuse +{ + for (MYSFormElement *element in self.elements) { + [self registerCellForClass:[element cellClass]]; + } + + // register metadata cells + [self registerCellForClass:[MYSFormMessageChildCell class]]; + [self registerCellForClass:[MYSFormLoadingChildCell class]]; + + // register view child cell + [self.collectionView registerClass:[MYSFormViewChildCell class] forCellWithReuseIdentifier:NSStringFromClass([MYSFormViewChildCell class])]; +} + #pragma mark (helpers) - (NSIndexPath *)indexPathOfElement:(MYSFormElement *)element