Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1738fb8e35 | |||
| c3be940cc4 | |||
| dddbb74e95 | |||
| ef90f35a0f | |||
| c03878e656 | |||
| 853254d75e | |||
| 460b116018 | |||
| 6a501e21fb | |||
| 6725d0a9b4 | |||
| daaf720c29 | |||
| bcd9ef118e | |||
| cb9d40ba3a | |||
| afcf2071ed | |||
| 12b7012a1b | |||
| 8632b5bb42 | |||
| ff2d869ee0 |
@@ -169,7 +169,7 @@ NSString * kAccessoryViewNotes = @"notes";
|
||||
[row.cellConfigAtConfigure setObject:@"TEXT VIEW EXAMPLE" forKey:@"textView.placeholder"];
|
||||
[section addFormRow:row];
|
||||
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:kAccessoryViewCheck rowType:XLFormRowDescriptorTypeBooleanCheck title:@"Ckeck"];
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:kAccessoryViewCheck rowType:XLFormRowDescriptorTypeBooleanCheck title:@"Check"];
|
||||
[section addFormRow:row];
|
||||
|
||||
section = [XLFormSectionDescriptor formSection];
|
||||
|
||||
@@ -170,7 +170,7 @@ NSString * kAccessoryViewNotes = @"notes";
|
||||
[row.cellConfigAtConfigure setObject:@"TEXT VIEW EXAMPLE" forKey:@"textView.placeholder"];
|
||||
[section addFormRow:row];
|
||||
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:kAccessoryViewCheck rowType:XLFormRowDescriptorTypeBooleanCheck title:@"Ckeck"];
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:kAccessoryViewCheck rowType:XLFormRowDescriptorTypeBooleanCheck title:@"Check"];
|
||||
[section addFormRow:row];
|
||||
|
||||
section = [XLFormSectionDescriptor formSectionWithTitle:@"TextView With Label Example"];
|
||||
|
||||
@@ -142,7 +142,7 @@ class AccessoryViewFormViewController : XLFormViewController {
|
||||
row.cellConfigAtConfigure["textView.placeholder"] = "TEXT VIEW EXAMPLE"
|
||||
section.addFormRow(row)
|
||||
|
||||
row = XLFormRowDescriptor(tag: Tags.AccessoryViewCheck.rawValue, rowType:XLFormRowDescriptorTypeBooleanCheck, title:"Ckeck")
|
||||
row = XLFormRowDescriptor(tag: Tags.AccessoryViewCheck.rawValue, rowType:XLFormRowDescriptorTypeBooleanCheck, title:"Check")
|
||||
section.addFormRow(row)
|
||||
|
||||
section = XLFormSectionDescriptor()
|
||||
|
||||
@@ -4,6 +4,7 @@ XLForm
|
||||
By [XMARTLABS](http://xmartlabs.com).
|
||||
|
||||
[](https://travis-ci.org/xmartlabs/XLForm)
|
||||
[](https://github.com/xmartlabs/XLForm/releases)
|
||||
|
||||
Purpose
|
||||
--------------
|
||||
@@ -934,12 +935,12 @@ Each XLFormDateCell has a `minimumDate` and a `maximumDate` property. To set a d
|
||||
row.cellConfig.setObject(NSDate(), forKey: "maximumDate")
|
||||
```
|
||||
|
||||
####How to disable the entire form (read only mode).
|
||||
#### How to disable the entire form (read only mode).
|
||||
|
||||
`disable` XLFormDescriptor property can be used to disable the entire form. In order to make the displayed cell to take effect we should reload the visible cells ( [self.tableView reloadData] ).
|
||||
Any other row added after form `disable` property is set to `YES` will reflect the disable mode automatically (no need to reload table view).
|
||||
|
||||
####How to hide a row or section when another rows value changes.
|
||||
#### How to hide a row or section when another rows value changes.
|
||||
|
||||
To hide a row or section you should set its hidden property. The easiest way of doing this is by setting a NSString to it. Let's say you want a section to hide if a previous row, which is a boolean switch, is set to 1 (or YES). Then you would do something like this:
|
||||
```objc
|
||||
@@ -947,24 +948,37 @@ section.hidden = [NSString stringWithFormat:@"$%@ == 1", previousRow];
|
||||
```
|
||||
That is all!
|
||||
|
||||
####What do I have to do to migrate from version 2.2.0 to 3.0.0?
|
||||
#### What do I have to do to migrate from version 2.2.0 to 3.0.0?
|
||||
|
||||
The only thing that is not compatible with older versions is that the `disabled` property of the `XLFormRowDescriptor` is an `id` now. So you just have to add `@` before the values you set to it like this:
|
||||
```objc
|
||||
row.disabled = @YES; // before: row.disabled = YES;
|
||||
```
|
||||
|
||||
##### How to disable input accessory view (navigation view)
|
||||
#### How to change input accessory view (navigation view)
|
||||
|
||||
Overriding `inputAccessoryViewForRowDescriptor:` `XLFormViewController` method.
|
||||
If you want to disable it completely you can return nil. But you can also customize its whole appearance here.
|
||||
|
||||
```obj-c
|
||||
- (UIView *)inputAccessoryViewForRowDescriptor:(XLFormRowDescriptor *)rowDescriptor {
|
||||
return nil;
|
||||
- (UIView *)inputAccessoryViewForRowDescriptor:(XLFormRowDescriptor *)rowDescriptor
|
||||
{
|
||||
return nil; //will hide it completely
|
||||
// You can use the rowDescriptor parameter to hide/customize the accessory view for a particular rowDescriptor type.
|
||||
}
|
||||
```
|
||||
|
||||
#### How to set up a pushed view controller?
|
||||
|
||||
The view controller that will be pushed must conform to the `XLFormRowDescriptorViewController` protocol which consists of the following property:
|
||||
```objc
|
||||
@property (nonatomic) XLFormRowDescriptor * rowDescriptor;
|
||||
```
|
||||
This rowDescriptor refers to the selected row of the previous view controller and will be set before the transition to the new controller so that it will be accessible for example in its `viewDidLoad` method. That is where that view controller should be set up.
|
||||
|
||||
#### How to change the default appearance of a certain cell
|
||||
|
||||
The best way to do this is to extend the class of that cell and override its update and/or configure methods. To make this work you should also update the `cellClassesForRowDescriptorTypes` dictionary in your subclass of XLFormViewController by setting your custom class instead of the class of the cell you wanted to change.
|
||||
|
||||
Installation
|
||||
--------------------------
|
||||
@@ -972,7 +986,7 @@ Installation
|
||||
The easiest way to use XLForm in your app is via [CocoaPods](http://cocoapods.org/ "CocoaPods").
|
||||
|
||||
1. Add the following line in the project's Podfile file:
|
||||
`pod 'XLForm', '~> 3.0.0'`.
|
||||
`pod 'XLForm', '~> 3.0'`.
|
||||
2. Run the command `pod install` from the Podfile folder directory.
|
||||
|
||||
XLForm **has no** dependencies over other pods.
|
||||
@@ -1008,6 +1022,9 @@ Requirements
|
||||
Release Notes
|
||||
--------------
|
||||
|
||||
Version 3.0.2
|
||||
* Fix issue when inline pickers expand beyond table.
|
||||
|
||||
Version 3.0.1
|
||||
|
||||
* Improvements and bug fixes.
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'XLForm'
|
||||
s.version = '3.0.1'
|
||||
s.version = '3.0.2'
|
||||
s.license = { :type => 'MIT' }
|
||||
s.summary = 'XLForm is the most flexible and powerful iOS library to create dynamic table-view forms.'
|
||||
s.description = <<-DESC
|
||||
@@ -8,7 +8,7 @@ Pod::Spec.new do |s|
|
||||
DESC
|
||||
s.homepage = 'https://github.com/xmartlabs/XLForm'
|
||||
s.authors = { 'Martin Barreto' => 'martin@xmartlabs.com' }
|
||||
s.source = { :git => 'https://github.com/xmartlabs/XLForm.git', :tag => 'v3.0.1' }
|
||||
s.source = { :git => 'https://github.com/xmartlabs/XLForm.git', :tag => 'v3.0.2' }
|
||||
s.source_files = 'XLForm/XL/**/*.{h,m}'
|
||||
s.requires_arc = true
|
||||
s.ios.deployment_target = '7.0'
|
||||
|
||||
@@ -81,6 +81,7 @@
|
||||
inlineCell.inlineRowDescriptor = self.rowDescriptor;
|
||||
|
||||
[formSection addFormRow:datePickerRowDescriptor afterRow:self.rowDescriptor];
|
||||
[self.formViewController ensureRowIsVisible:datePickerRowDescriptor];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
UITableViewCell<XLFormInlineRowDescriptorCell> * inlineCell = (UITableViewCell<XLFormInlineRowDescriptorCell> *)cell;
|
||||
inlineCell.inlineRowDescriptor = self.rowDescriptor;
|
||||
[self.rowDescriptor.sectionDescriptor addFormRow:inlineRowDescriptor afterRow:self.rowDescriptor];
|
||||
[self.formViewController ensureRowIsVisible:inlineRowDescriptor];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -74,6 +74,8 @@ typedef NS_ENUM(NSUInteger, XLFormRowNavigationDirection) {
|
||||
-(void)beginEditing:(XLFormRowDescriptor *)rowDescriptor;
|
||||
-(void)endEditing:(XLFormRowDescriptor *)rowDescriptor;
|
||||
|
||||
-(void)ensureRowIsVisible:(XLFormRowDescriptor *)inlineRowDescriptor;
|
||||
|
||||
@end
|
||||
|
||||
@interface XLFormViewController : UIViewController<UITableViewDataSource, UITableViewDelegate, XLFormDescriptorDelegate, UITextFieldDelegate, UITextViewDelegate, UIActionSheetDelegate, XLFormViewControllerDelegate>
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
@interface XLFormViewController()
|
||||
{
|
||||
NSNumber *_oldBottomTableContentInset;
|
||||
CGRect _keyboardFrame;
|
||||
}
|
||||
@property UITableViewStyle tableViewStyle;
|
||||
@property (nonatomic) XLFormRowNavigationAccessoryView * navigationAccessoryView;
|
||||
@@ -148,7 +149,8 @@
|
||||
NSIndexPath *selected = [self.tableView indexPathForSelectedRow];
|
||||
if (selected){
|
||||
// Trigger a cell refresh
|
||||
[self tableView:self.tableView cellForRowAtIndexPath:selected];
|
||||
XLFormRowDescriptor * rowDescriptor = [self.form formRowAtIndex:selected];
|
||||
[self updateFormRow:rowDescriptor];
|
||||
[self.tableView selectRowAtIndexPath:selected animated:NO scrollPosition:UITableViewScrollPositionNone];
|
||||
[self.tableView deselectRowAtIndexPath:selected animated:YES];
|
||||
}
|
||||
@@ -259,7 +261,8 @@
|
||||
@{XLFormRowDescriptorTypeSelectorPickerViewInline: XLFormRowDescriptorTypePicker,
|
||||
XLFormRowDescriptorTypeDateInline: XLFormRowDescriptorTypeDatePicker,
|
||||
XLFormRowDescriptorTypeDateTimeInline: XLFormRowDescriptorTypeDatePicker,
|
||||
XLFormRowDescriptorTypeTimeInline: XLFormRowDescriptorTypeDatePicker
|
||||
XLFormRowDescriptorTypeTimeInline: XLFormRowDescriptorTypeDatePicker,
|
||||
XLFormRowDescriptorTypeCountDownTimerInline: XLFormRowDescriptorTypeDatePicker
|
||||
} mutableCopy];
|
||||
});
|
||||
return _inlineRowDescriptorTypesForRowDescriptorTypes;
|
||||
@@ -439,6 +442,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
-(void)ensureRowIsVisible:(XLFormRowDescriptor *)inlineRowDescriptor
|
||||
{
|
||||
XLFormBaseCell * inlineCell = [inlineRowDescriptor cellForFormController:self];
|
||||
NSIndexPath * indexOfOutOfWindowCell = [self.form indexPathOfFormRow:inlineRowDescriptor];
|
||||
if(!inlineCell.window || (self.tableView.contentOffset.y + self.tableView.frame.size.height <= inlineCell.frame.origin.y + inlineCell.frame.size.height)){
|
||||
[self.tableView scrollToRowAtIndexPath:indexOfOutOfWindowCell atScrollPosition:UITableViewScrollPositionBottom animated:YES];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Methods
|
||||
|
||||
-(NSArray *)formValidationErrors
|
||||
@@ -500,12 +512,12 @@
|
||||
UITableViewCell<XLFormDescriptorCell> * cell = [firstResponderView formDescriptorCell];
|
||||
if (cell){
|
||||
NSDictionary *keyboardInfo = [notification userInfo];
|
||||
CGRect keyboardFrame = [self.tableView.window convertRect:[keyboardInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue] toView:self.tableView.superview];
|
||||
CGFloat newBottomInset = self.tableView.frame.origin.y + self.tableView.frame.size.height - keyboardFrame.origin.y;
|
||||
if (newBottomInset > 0){
|
||||
UIEdgeInsets tableContentInset = self.tableView.contentInset;
|
||||
UIEdgeInsets tableScrollIndicatorInsets = self.tableView.scrollIndicatorInsets;
|
||||
_oldBottomTableContentInset = _oldBottomTableContentInset ? : @(tableContentInset.bottom);
|
||||
_keyboardFrame = [self.tableView.window convertRect:[keyboardInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue] toView:self.tableView.superview];
|
||||
CGFloat newBottomInset = self.tableView.frame.origin.y + self.tableView.frame.size.height - _keyboardFrame.origin.y;
|
||||
UIEdgeInsets tableContentInset = self.tableView.contentInset;
|
||||
UIEdgeInsets tableScrollIndicatorInsets = self.tableView.scrollIndicatorInsets;
|
||||
_oldBottomTableContentInset = _oldBottomTableContentInset ?: @(tableContentInset.bottom);
|
||||
if (newBottomInset > [_oldBottomTableContentInset floatValue]){
|
||||
tableContentInset.bottom = newBottomInset;
|
||||
tableScrollIndicatorInsets.bottom = tableContentInset.bottom;
|
||||
[UIView beginAnimations:nil context:nil];
|
||||
@@ -525,6 +537,7 @@
|
||||
UIView * firstResponderView = [self.tableView findFirstResponder];
|
||||
UITableViewCell<XLFormDescriptorCell> * cell = [firstResponderView formDescriptorCell];
|
||||
if (cell){
|
||||
_keyboardFrame = CGRectZero;
|
||||
NSDictionary *keyboardInfo = [notification userInfo];
|
||||
UIEdgeInsets tableContentInset = self.tableView.contentInset;
|
||||
UIEdgeInsets tableScrollIndicatorInsets = self.tableView.scrollIndicatorInsets;
|
||||
@@ -562,6 +575,7 @@
|
||||
{
|
||||
XLFormBaseCell * cell = [formRow cellForFormController:self];
|
||||
cell.rowDescriptor = formRow;
|
||||
[cell setNeedsUpdateConstraints];
|
||||
[cell setNeedsLayout];
|
||||
return cell;
|
||||
}
|
||||
@@ -585,7 +599,13 @@
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
XLFormRowDescriptor * rowDescriptor = [self.form formRowAtIndex:indexPath];
|
||||
return [self updateFormRow:rowDescriptor];
|
||||
return [rowDescriptor cellForFormController:self];
|
||||
}
|
||||
|
||||
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
XLFormRowDescriptor * rowDescriptor = [self.form formRowAtIndex:indexPath];
|
||||
[self updateFormRow:rowDescriptor];
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user