Skip to content

Commit

Permalink
Updated to version 1.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklockwood committed Apr 14, 2014
1 parent 9fd8ece commit 50d033e
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 38 deletions.
4 changes: 2 additions & 2 deletions FXForms.podspec
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Pod::Spec.new do |s|
s.name = 'FXForms'
s.version = '1.1.3'
s.version = '1.1.4'
s.license = 'zlib'
s.summary = 'FXForms is an Objective-C library for easily creating table-based forms on iOS. It is ideal for settings pages or user data entry tasks.'
s.homepage = 'https://github.com/nicklockwood/FXForms'
s.authors = 'Nick Lockwood'
s.source = { :git => "https://github.com/nicklockwood/FXForms.git", :tag => "1.1.3" }
s.source = { :git => "https://github.com/nicklockwood/FXForms.git", :tag => "1.1.4" }
s.source_files = 'FXForms'
s.requires_arc = true
s.ios.deployment_target = '5.0'
Expand Down
2 changes: 1 addition & 1 deletion FXForms/FXForms.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FXForms.h
//
// Version 1.1.3
// Version 1.1.4
//
// Created by Nick Lockwood on 13/02/2014.
// Copyright (c) 2014 Charcoal Design. All rights reserved.
Expand Down
91 changes: 58 additions & 33 deletions FXForms/FXForms.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FXForms.m
//
// Version 1.1.3
// Version 1.1.4
//
// Created by Nick Lockwood on 13/02/2014.
// Copyright (c) 2014 Charcoal Design. All rights reserved.
Expand Down Expand Up @@ -1089,6 +1089,9 @@ - (instancetype)init

- (void)dealloc
{
_tableView.dataSource = nil;
_tableView.delegate = nil;

[[NSNotificationCenter defaultCenter] removeObserver:self];
}

Expand Down Expand Up @@ -1441,6 +1444,11 @@ @implementation FXFormViewController

@synthesize field = _field;

- (void)dealloc
{
_formController.delegate = nil;
}

- (void)setField:(FXFormField *)field
{
_field = field;
Expand Down Expand Up @@ -1522,13 +1530,6 @@ - (void)viewWillAppear:(BOOL)animated
#pragma mark Views


@interface FXFormBaseCell ()

@property (nonatomic, strong) UITextField *textField;

@end


@implementation FXFormBaseCell

@synthesize field = _field;
Expand Down Expand Up @@ -1739,6 +1740,11 @@ - (void)setUp
[self addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self.textField action:NSSelectorFromString(@"becomeFirstResponder")]];
}

- (void)dealloc
{
_textField.delegate = nil;
}

- (void)setValue:(id)value forKeyPath:(NSString *)keyPath
{
//TODO: is there a less hacky fix for this?
Expand Down Expand Up @@ -1950,13 +1956,22 @@ - (void)setUp
self.textView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin;
self.textView.font = [UIFont systemFontOfSize:17];
self.textView.textColor = [UIColor colorWithRed:0.275f green:0.376f blue:0.522f alpha:1.000f];
self.textView.backgroundColor = [UIColor clearColor];
self.textView.delegate = self;
self.textView.scrollEnabled = NO;
[self.contentView addSubview:self.textView];

self.detailTextLabel.textAlignment = UITextAlignmentLeft;
self.detailTextLabel.numberOfLines = 0;

[self addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self.textView action:NSSelectorFromString(@"becomeFirstResponder")]];
}

- (void)dealloc
{
_textView.delegate = nil;
}

- (void)layoutSubviews
{
[super layoutSubviews];
Expand All @@ -1976,9 +1991,12 @@ - (void)layoutSubviews
{
textViewFrame.origin.y = self.textLabel.frame.origin.y;
}

self.textView.frame = textViewFrame;

textViewFrame.origin.x += 5;
textViewFrame.size.width -= 5;
self.detailTextLabel.frame = textViewFrame;

CGRect contentViewFrame = self.contentView.frame;
contentViewFrame.size.height = self.textView.frame.origin.y + self.textView.frame.size.height + FXFormFieldPaddingBottom;
self.contentView.frame = contentViewFrame;
Expand All @@ -1987,6 +2005,7 @@ - (void)layoutSubviews
- (void)update
{
self.textLabel.text = self.field.title;
self.detailTextLabel.text = self.field.placeholder;
self.textView.text = [self.field fieldDescription];

self.textView.returnKeyType = UIReturnKeyDefault;
Expand Down Expand Up @@ -2033,25 +2052,21 @@ - (void)textViewDidBeginEditing:(__unused UITextView *)textView
[self.textView selectAll:nil];
}

- (void)textViewDidChange:(__unused UITextView *)textView
- (void)textViewDidChange:(UITextView *)textView
{
[self updateFieldValue];
// resize the tableview if required
id responder = [self nextResponder];
while (responder)
{
if ([responder respondsToSelector:@selector(beginUpdates)] &&
[responder respondsToSelector:@selector(endUpdates)])
{
[responder beginUpdates];
[responder endUpdates];

CGRect caretRect = [self.textView caretRectForPosition:self.textView.selectedTextRange.end];
[responder scrollRectToVisible:[responder convertRect:caretRect fromView:self.textView] animated:YES];
break;
}
responder = [responder nextResponder];
}

//show/hide placeholder
self.detailTextLabel.hidden = ([textView.text length] > 0);

//resize the tableview if required
UITableView *tableView = [self tableView];
[tableView beginUpdates];
[tableView endUpdates];

//scroll to show cursor
CGRect cursorRect = [self.textView caretRectForPosition:self.textView.selectedTextRange.end];
[tableView scrollRectToVisible:[tableView convertRect:cursorRect fromView:self.textView] animated:YES];
}

- (void)textViewDidEndEditing:(__unused UITextView *)textView
Expand Down Expand Up @@ -2087,7 +2102,7 @@ - (BOOL)canBecomeFirstResponder

- (BOOL)becomeFirstResponder
{
return [self.textField becomeFirstResponder];
return [self.textView becomeFirstResponder];
}

@end
Expand Down Expand Up @@ -2305,15 +2320,19 @@ - (void)setUp
[self setNeedsLayout];
}

- (void)dealloc
{
_imagePickerController.delegate = nil;
}

- (void)layoutSubviews
{
[super layoutSubviews];

CGRect frame = self.imagePickerView.frame;
CGRect frame = self.imagePickerView.bounds;
frame.size.height = self.bounds.size.height - 10;
frame.size.width = self.imagePickerView.image? self.imagePickerView.image.size.width / self.imagePickerView.image.size.height: 0;
frame.size.width = MIN(self.bounds.size.width - self.textLabel.frame.origin.x - self.textField.frame.size.width - FXFormFieldPaddingLeft, MAX(frame.size.height, frame.size.width));
self.imagePickerView.frame = frame;
frame.size.width = self.imagePickerView.image? self.imagePickerView.image.size.width / frame.size.height: 0;
self.imagePickerView.bounds = frame;

[super layoutSubviews];
}

- (void)update
Expand Down Expand Up @@ -2411,6 +2430,12 @@ - (void)setUp
self.pickerView.delegate = self;
}

- (void)dealloc
{
_pickerView.dataSource = nil;
_pickerView.delegate = nil;
}

- (void)update
{
self.textLabel.text = self.field.title;
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FXForms

version 1.1.3, April 11th, 2014
version 1.1.4, April 14th, 2014

Copyright (C) 2014 Charcoal Design

Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,15 @@ Once you have created your custom cell, you can use it as follows:
Release notes
--------------

Version 1.1.4

- FXForms now nils out all control delegates & datasources correctly to prevent crashes when form is dismissed
- The FXFormImagePickerCell image is no longer drawn with incorrect alignment
- FXFormTextViewCell can now display placeholder text when empty

Version 1.1.3

- using <propertyName>Field method to set form properties is no longer overridden by defaults
- Using <propertyName>Field method to set form properties is no longer overridden by defaults
- Only mess with the content inset/offset when the view controller is not a UITableViewController
- It should now be easier to use nibs to lay out cell subclasses without losing standard functionality
- Using FXFormFieldTypeLabel now works more consistently
Expand Down

0 comments on commit 50d033e

Please sign in to comment.