CocoaPods trunk is moving to be read-only. Read more on the blog, there are 11 months to go.
| TestsTested | ✗ |
| LangLanguage | Obj-CObjective C |
| License | MIT |
| ReleasedLast Release | Oct 2017 |
Maintained by Mauricio Tremea Zaquia.
MTZTableViewManager is a powerful framework that allows you to create table views in a descriptive way, by specifying rows and sections without having to bother with indexes. It also provides a set of tools for creating forms and handling their input, applying masks, performing validations and converting to and from complex objects.
1.1.3 at the moment).MTZTableViewManager.xcodeproj inside your Xcode project.MTZTableViewManager.framework (under Products) to your target Linked Frameworks and Libraries area.Getting started is fairly simple. Just declare a strongly-held MTZTableManager somewhere:
@property (nonatomic) MTZTableManager *tableManager;Then declare your rows, sections and finally the data. Using a custom UITableViewCell subclass is recommended.
MTZTableRow *row = [[MTZTableRow alloc] initWithClazz:[MyCustomCell class] action:^(NSIndexPath * _Nonnull indexPath, id<MTZModel> model) {
NSLog(@"Tap!");
}];
MTZTableSection *section = [[MTZTableSection alloc] initWithTableRows:@[row]];
MTZTableData *data = [[MTZTableData alloc] initWithTableSections:@[section]];
self.tableManager = [[MTZTableManager alloc] initWithTableView:self.tableView tableData:data];And you're good to go! Please note you cannot be the tableViews delegate or data source while using MTZTableManager.
hidden property.nibs as well. Likewise you can provide custom headers and footers classes for every section.To declare an object as a possible model, just conform it to MTZModel:
@interface MyCustomCellModel: NSObject<MTZModel>
@property (nonatomic) NSString *text;
@endCells can then be configured to display information. Simply conform the cell you want to MTZModelDisplaying and implement the required method:
@interface MyCustomCell: UITableViewCell <MTZModelDisplaying>
@end
@implementation MyCustomCell
- (void)configureWithModel:(id<MTZModel>)model {
self.textLabel.text = ((MyCustomCellModel *)model).text;
}
@endMTZModelDisplaying.Form objects are objects that can be manipulated by a form generated by MTZTableViewManager. Ideally, you want to make all of its properties read-only to avoid external mutation, since the form elements will modify the values directly via KVO. If you're using Swift. Don't forget the dynamic keyword for that! Make sure the object conforms to MTZFormObject:
@interface MyCustomFormObject: NSObject <MTZFormObject>
@property (nonatomic, readonly) NSString *title;
@property (nonatomic, readonly) NSDate *date;
@property (nonatomic, readonly) MyCustomUser *user;
@endFor a cell to be compatible with a form, it needs to conform with MTZFormEditing and implement the required method:
@interface MyCustomTextFieldCell: UITableViewCell <MTZFormEditing>
@property (nonatomic) UITextField *textField;
@end
@implementation MyCustomTextFieldCell
// ...
- (UIControl<MTZFormField> *)fieldForFormObject {
return self.textField;
}
@endMTZFormField. The framework already provides a default implementation for UITextField, UITextView, UISwitch and UIStepper.Form fields automatically provide you with inputAccessoryView for jumping between other fields within the same section. To localise the buttons on the framework-provided input accessory view, simply add the following entries to your Localizable.strings, replacing the translations to whatever fits your needs:
"mtz_prev" = "Prev";
"mtz_next" = "Next";
"mtz_done" = "Done";Dates are a special topic. Due to that, if you want to interact with a NSDate key path, use MTZTableFormDateRow instead:
MTZTableFormDateRow *dateRow = [[MTZTableFormDateRow alloc] initWithClazz:[MyCustomTextFieldCell class] formObject:self.formObject keyPath:CLASSKEY(MyCustomFormObject, date)];
dateRow.minimumDate = [NSDate date];
dateRow.maximumDate = [[NSDate date] dateByAddingTimeInterval:60*60*24*15];
dateRow.datePickerMode = MTZDatePickerModeDateAndTime;MTZTableFormDateRow must also use UITextField as a form field, as we replace the inputView with the adequate picker.MTZDatePickerModeExpirationDate as a picker mode, and it will use the MTZExpirationDatePicker as inputView.If you want to provide a set of options, do so by conforming the type of object you want to provide as an option to MTZFormOption:
@interface MyCustomUser: NSObject <MTZFormOption>
@property (nonatomic) NSInteger ID;
@property (nonatomic) NSString *email;
- (instancetype)initWithID:(NSInteger)ID email:(NSString *)email;
@end
@implementation MyCustomUser
// ...
- (NSString *)optionDescription {
return self.email;
}
@endThen set the availableOptions property on the MTZTableFormRow:
NSArray *allUsers = @[[[MyCustomUser alloc] initWithID:1 email:@"[email protected]"],
[[MyCustomUser alloc] initWithID:2 email:@"[email protected]"],
[[MyCustomUser alloc] initWithID:3 email:@"[email protected]"]];
MTZTableFormRow *userRow = [[MTZTableFormRow alloc] initWithClazz:[MyCustomTextFieldCell class] formObject:self.formObject keyPath:CLASSKEY(MyCustomFormObject, user)];
userRow.availableOptions = allUsers;UITextField as a form field, as we replace the inputView with the adequate picker.TBA
TBA
TBA
TBA
MTZTableViewManager is released under the MIT license. See LICENSE for details.