GithubHelp home page GithubHelp logo

romaonthego / retableviewmanager Goto Github PK

View Code? Open in Web Editor NEW
2.5K 100.0 433.0 6.29 MB

Powerful data driven content manager for UITableView.

License: MIT License

Ruby 0.53% Objective-C 98.21% C 0.23% Shell 1.03%

retableviewmanager's Introduction

RETableViewManager

Powerful data driven content manager for UITableView.

RETableViewManager allows to manage the content of any UITableView with ease, both forms and lists. RETableViewManager is built on top of reusable cells technique and provides APIs for mapping any object class to any custom cell subclass.

The general idea is to allow developers to use their own UITableView and UITableViewController instances (and even subclasses), providing a layer that synchronizes data with the cell appearance. It fully implements UITableViewDelegate and UITableViewDataSource protocols so you don't have to.

RETableViewManager Screenshot

RETableViewManager Screenshot

RETableViewManager Screenshot

Quick Example

Get your UITableView up and running in several lines of code:

- (void)viewDidLoad
{
    [super viewDidLoad];

    // Create the manager and assign a UITableView
    //
    self.manager = [[RETableViewManager alloc] initWithTableView:self.tableView];

    // Add a section
    //
    RETableViewSection *section = [RETableViewSection sectionWithHeaderTitle:@"Test"];
    [self.manager addSection:section];

    // Add a string
    //
    [section addItem:@"Just a simple NSString"];

    // Add a basic cell with disclosure indicator
    //
    [section addItem:[RETableViewItem itemWithTitle:@"String cell" accessoryType:UITableViewCellAccessoryDisclosureIndicator selectionHandler:^(RETableViewItem *item) {
        NSLog(@"Test: %@", item);
    }]];

    // Custom items / cells
    //
    self.manager[@"CustomItem"] = @"CustomCell";

    [section addItem:[CustomItem item]];
}

RETableViewManager comes pre-packaged with extensible and ready-to-use in production components:

  • Text
  • Bool
  • Number
  • Float
  • Date/Time
  • Long Text
  • Radio option selector
  • Multiple option selector
  • Credit card and expiration date

Also RETableViewManager provides APIs for super easy cell styling.

Requirements

  • Xcode 5 or higher
  • Apple LLVM compiler
  • iOS 7.0 or higher
  • ARC

Demo

Build and run the RETableViewManagerExample.xcworkspace in Xcode to see RETableViewManager in action.

Installation

1) CocoaPods

The recommended approach for installing RETableViewManager is via the CocoaPods package manager, as it provides flexible dependency management and dead simple installation. For best results, it is recommended that you install via CocoaPods >= 0.28.0 using Git >= 1.8.0 installed via Homebrew.

Install CocoaPods if not already available:

$ [sudo] gem install cocoapods
$ pod setup

Change to the directory of your Xcode project:

$ cd /path/to/MyProject
$ touch Podfile
$ edit Podfile

Edit your Podfile and add RETableViewManager:

platform :ios, '7.0'
pod 'RETableViewManager', '~> 1.6'

Install into your Xcode project:

$ pod install

Open your project in Xcode from the .xcworkspace file (not the usual project file)

$ open MyProject.xcworkspace

Please note that if your installation fails, it may be because you are installing with a version of Git lower than CocoaPods is expecting. Please ensure that you are running Git >= 1.8.0 by executing git --version. You can get a full picture of the installation details by executing pod install --verbose.

2) Include Source Code

Include RETableViewManager, REValidation, Resources, REFormattedNumberField folders in your source code

API Quickstart

Key Classes
RETableViewManager The manager class. Each manager has multiple RETableViewSection sections.
RETableViewSection Represents sections in RETableViewManager, each section has multiple RETableViewItem items.
RETableViewItem RETableViewItem is the root class of most RETableViewManager item hierarchies.
Through RETableViewItem, items inherit a basic interface that communicates with RETableViewCell and RETableViewManager.
RETableViewCell The RETableViewCell class defines the attributes and behavior of the cells that appear in UITableView objects. You should subclass RETableViewCell to obtain cell characteristics and behavior specific to your application's needs. By default, RETableViewCell is being mapped with RETableViewItem.
Styling
RETableViewCellStyle Provides style for RETableViewCell subclasses. You can define such properties as backgroundImageMargin, cellHeight, contentViewMargin and more.
Helper Controllers
RETableViewOptionsController Performs selection based on user input and provides result on completion. Should be used with RERadioItem.

RETableViewManager includes a number of built-in items and cells that perform common tasks (text input, date input and so on).

Built-in Items and Cells
Item Class Cell Class Description
RETextItem RETableViewTextCell Provides convenience for a user text input. You can set a bunch of properties through RETextItem that you would normally find in UITextField.
RELongTextItem RETableViewLongTextCell Provides convenience for a multiline user text input. You can set a bunch of properties through RELongTextItem that you would normally find in UITextView.
RENumberItem RETableViewNumberCell Provides convenience for a user number input using REFormattedNumberField.
REBoolItem RETableViewBoolCell Provides convenience for a user boolean input using UISwitch.
RERadioItem RETableViewCell Provides convenience for selecting a single option using RETableViewOptionsController.
REMultipleChoiceItem RETableViewCell Provides convenience for selecting multiple options using RETableViewOptionsController.
REFloatItem RETableViewFloatCell Provides convenience for adjusting float values ranging from 0.0 to 1.0.
REDateTimeItem RETableViewDateTimeCell Provides convenience for modifying date in NSDate objects.
REPickerItem RETableViewPickerCell Provides convenience for selecting multiple options using UIPickerView.
RESegmentedItem RETableViewSegmentedCell Provides convenience for working with UISegmentedControl.
RECreditCardItem RETableViewCreditCardCell Provides convenience for a user credit card input. Allows to enter a credit card number, expiration date and security code, all in a single table view cell.

Examples

Creating Sections Example

Section without a title:

RETableViewSection *section = [RETableViewSection section];
[self.manager addSection:section];

Section with a title:

RETableViewSection *section = [RETableViewSection sectionWithHeaderTitle:@"Header"];
[self.manager addSection:section];

Section with a title and a footer:

RETableViewSection *section = [RETableViewSection sectionWithHeaderTitle:@"Header" footerTitle:@"Footer"];
[self.manager addSection:section];

Section with a custom header view:

RETableViewSection *section = [RETableViewSection sectionWithHeaderView:myCustomSectionHeaderView];
[self.manager addSection:section];

Section with a custom header and footer view:

RETableViewSection *section = [RETableViewSection sectionWithHeaderView:myCustomSectionHeaderView footerView:myCustomSectionFooterView];
[self.manager addSection:section];

Text (UITextField) and Number (REFormattedNumberField) Item Example

// Create the manager
//
self.manager = [[RETableViewManager alloc] initWithTableView:self.tableView];

// Add a section
//
RETableViewSection *section = [RETableViewSection sectionWithHeaderTitle:@"Test"];
[self.manager addSection:section];

// Add items to the section
//
self.textItem = [RETextItem itemWithTitle:@"Enter text" value:@""];
[section addItem:self.textItem];

self.numberItem = [RENumberItem itemWithTitle:@"Enter text" value:@"" placeholder:@"(123) 456-7890" format:@"(XXX) XXX-XXXX"];
[section addItem:self.numberItem];

You can read self.textItem.value and self.numberItem.value later whenever you need them.

Bool Item (UISwitch) Example

// Create the manager
//
self.manager = [[RETableViewManager alloc] initWithTableView:self.tableView];

// Add a section
//
RETableViewSection *section = [RETableViewSection sectionWithHeaderTitle:@"Test"];
[self.manager addSection:section];

// Add a bool value cell (using UISwitch)
//
[section addItem:[REBoolItem itemWithTitle:@"Switch test" value:YES switchValueChangeHandler:^(REBoolItem *item) {
    NSLog(@"Value: %i", item.value);
}]];

Radio (RETableViewOptionsController) Item Example

// Create the manager
//
self.manager = [[RETableViewManager alloc] initWithTableView:self.tableView];

// Add a section
//
RETableViewSection *section = [RETableViewSection sectionWithHeaderTitle:@"Test"];
[self.manager addSection:section];

// Add radio cell (options)
//

    __typeof (&*self) __weak weakSelf = self;

     RERadioItem *radioItem = [RERadioItem itemWithTitle:@"Radio" value:@"Option 4" selectionHandler:^(RERadioItem *item) {
        [item deselectRowAnimated:YES]; // same as [weakSelf.tableView deselectRowAtIndexPath:item.indexPath animated:YES];

        // Generate sample options
        //
        NSMutableArray *options = [[NSMutableArray alloc] init];
        for (NSInteger i = 1; i < 40; i++)
            [options addObject:[NSString stringWithFormat:@"Option %li", (long) i]];

        // Present options controller
        //
        RETableViewOptionsController *optionsController = [[RETableViewOptionsController alloc] initWithItem:item options:options multipleChoice:NO completionHandler:^{
            [weakSelf.navigationController popViewControllerAnimated:YES];

            [item reloadRowWithAnimation:UITableViewRowAnimationNone]; // same as [weakSelf.tableView reloadRowsAtIndexPaths:@[item.indexPath] withRowAnimation:UITableViewRowAnimationNone];
        }];

        // Adjust styles
        //
        optionsController.delegate = weakSelf;
        optionsController.style = section.style;
        if (weakSelf.tableView.backgroundView == nil) {
            optionsController.tableView.backgroundColor = weakSelf.tableView.backgroundColor;
            optionsController.tableView.backgroundView = nil;
        }

        // Push the options controller
        //
        [weakSelf.navigationController pushViewController:optionsController animated:YES];
    }];

    [section addItem:radioItem];

Float Item (UISlider) Example

// Create the manager
//
self.manager = [[RETableViewManager alloc] initWithTableView:self.tableView];

// Add a section
//
RETableViewSection *section = [RETableViewSection sectionWithHeaderTitle:@"Test"];
[self.manager addSection:section];

// Add a float item
//
[section addItem:[REFloatItem itemWithTitle:@"Float item" value:0.3 sliderValueChangeHandler:^(REFloatItem *item) {
    NSLog(@"Value: %f", item.value);
}]];

Date Item Example

// Create the manager
//
self.manager = [[RETableViewManager alloc] initWithTableView:self.tableView];

// Add a section
//
RETableViewSection *section = [RETableViewSection sectionWithHeaderTitle:@"Test"];
[self.manager addSection:section];

// Add a date item
//
[section addItem:[REDateTimeItem itemWithTitle:@"Date / Time" value:[NSDate date] placeholder:nil format:@"MM/dd/yyyy hh:mm a" datePickerMode:UIDatePickerModeDateAndTime]];

Picker Item Example

// Create the manager
//
self.manager = [[RETableViewManager alloc] initWithTableView:self.tableView];

// Add a section
//
RETableViewSection *section = [RETableViewSection sectionWithHeaderTitle:@"Test"];
[self.manager addSection:section];

// Add a picker item
//
[section addItem:[REPickerItem itemWithTitle:@"Picker" value:@[@"Item 12", @"Item 23"] placeholder:nil options:@[@[@"Item 11", @"Item 12", @"Item 13"], @[@"Item 21", @"Item 22", @"Item 23", @"Item 24"]]]];

Segmented Item Example

// Create the manager
//
self.manager = [[RETableViewManager alloc] initWithTableView:self.tableView];

// Add a section
//
RETableViewSection *section = [RETableViewSection sectionWithHeaderTitle:@"Test"];
[self.manager addSection:section];

// Add a segmented item
//
[section addItem:[RESegmentedItem itemWithTitles:@[@"One", @"Two"] value:1 switchValueChangeHandler:^(RESegmentedItem *item) {
    NSLog(@"Value: %i", item.value);
}]];

Validations

Validations are performed using REValidation library.

Example:

self.textItem = [RETextItem itemWithTitle:@"Text" value:@"" placeholder:@"Text item"];
self.textItem.validators = @[@"presence", @"length(3, 10)"];

self.emailItem = [RETextItem itemWithTitle:@"Email" value:@"" placeholder:@"Email item"];
self.emailItem.name = @"Your email";
self.emailItem.validators = @[@"presence", @"email"];

Each item, each section and the manager have property errors. This property is always up to date with errors on each level. For example, an RETableViewItem would only have its own validation errors, RETableViewSection would have all errors that occured in that section (one per item). RETableViewManager's property errors would reflect all errors.

Custom Cells

RETableViewManager allows to map custom objects to custom cells. In order to map your custom object (an item) to a cell, simply write:

self.manager[@"CustomItem"] = @"CustomCell";

If you take a look at RETableViewManager Source Code you may find out how default mapping is being performed:

- (void)registerDefaultClasses
{
    self[@"__NSCFConstantString"] = @"RETableViewCell";
    self[@"__NSCFString"] = @"RETableViewCell";
    self[@"NSString"] = @"RETableViewCell";
    self[@"RETableViewItem"] = @"RETableViewCell";
    self[@"RERadioItem"] = @"RETableViewOptionCell";
    self[@"REBoolItem"] = @"RETableViewBoolCell";
    self[@"RETextItem"] = @"RETableViewTextCell";
    self[@"RELongTextItem"] = @"RETableViewLongTextCell";
    self[@"RENumberItem"] = @"RETableViewNumberCell";
    self[@"REFloatItem"] = @"RETableViewFloatCell";
    self[@"REDateTimeItem"] = @"RETableViewDateTimeCell";
    self[@"RECreditCardItem"] = @"RETableViewCreditCardCell";
    self[@"REMultipleChoiceItem"] = @"RETableViewOptionCell";
}

Your custom items should be subclassed from RETableViewItem. Custom cells should be subclassed from RETableViewCell. These are 2 base classes that provide all necessary logic to bound your subclasses together.

In your RETableViewCell subclass you need to link an item object with your item. This could be simply done by declaring it:

#import <RETableViewManager/RETableViewManager.h>
#import "CustomItem.h"

@interface CustomCell : RETableViewCell

@property (strong, readwrite, nonatomic) CustomItem *item;

@end

After that your custom object (item) is ready to use within the cell.

There are 3 basic methods of RETableViewCell that you need to implement:

  • Class method to adjust cell size:
+ (CGFloat)heightWithItem:(RETableViewItem *)item tableViewManager:(RETableViewManager *)tableViewManager;

Your custom item will be passed to this method in order to determine cell size. You need to return the calculated size.

  • Instance method that is being fired when the cell is being created.
- (void)cellDidLoad;

You might want to create cell subviews here. This method will be called only once, after that the cell will be reused.

  • Instance method that is being fired each time the cell is being reused.
- (void)cellWillAppear;

cellWillAppear is a great place to assign values to labels (from your custom item), adjust colors, etc.

Quick example:

- (void)cellDidLoad
{
    [super cellDidLoad];
    self.testLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 44)];
    [self.contentView addSubview:self.testLabel];
}

- (void)cellWillAppear
{
    [super cellWillAppear];
    self.testLabel.text = self.item.someVariable;
}

Interface Builder Support

Interface builder cells are supported out of the box, no special set up needed. Cells and items are being automatically registered like any other custom cells in RETableViewManager:

self.manager[@"XIBTestItem"] = @"XIBTestCell";

Here XIBTestItem would be your cell identifier and you should have the XIBTestCell.xib file in your bundle. That's it.

Styling

It's super easy to customize different offsets and cell background images of the entire UITableView (or any particular section) with RETableViewManager.

RETableViewManager and RETableViewSection both have the style property (an instance of the RETableViewCellStyle class).

Here's the quick example of how the custom styling works:

// Set default cell height
//
self.manager.style.cellHeight = 42.0;

// Set cell background image
//
[self.manager.style setBackgroundImage:[[UIImage imageNamed:@"First"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)]
                           forCellType:RETableViewCellTypeFirst];
[self.manager.style setBackgroundImage:[[UIImage imageNamed:@"Middle"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)]
                           forCellType:RETableViewCellTypeMiddle];
[self.manager.style setBackgroundImage:[[UIImage imageNamed:@"Last"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)]
                           forCellType:RETableViewCellTypeLast];
[self.manager.style setBackgroundImage:[[UIImage imageNamed:@"Single"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)]
                           forCellType:RETableViewCellTypeSingle];

// Set selected cell background image
//
[self.manager.style setSelectedBackgroundImage:[[UIImage imageNamed:@"First_Selected"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)]
                                   forCellType:RETableViewCellTypeFirst];
[self.manager.style setSelectedBackgroundImage:[[UIImage imageNamed:@"Middle_Selected"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)]
                                   forCellType:RETableViewCellTypeMiddle];
[self.manager.style setSelectedBackgroundImage:[[UIImage imageNamed:@"Last_Selected"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)]
                                   forCellType:RETableViewCellTypeLast];
[self.manager.style setSelectedBackgroundImage:[[UIImage imageNamed:@"Single_Selected"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)]
                                   forCellType:RETableViewCellTypeSingle];

self.manager.style.contentViewMargin = 10.0;
    self.manager.style.backgroundImageMargin = 10.0;

// Set a custom style for a particular section
//
self.accessoriesSection.style = [self.manager.style copy];
[self.accessoriesSection.style setBackgroundImage:[[UIImage imageNamed:@"First_Alt"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)]
                                      forCellType:RETableViewCellTypeFirst];
[self.accessoriesSection.style setBackgroundImage:[[UIImage imageNamed:@"Middle_Alt"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)]
                                      forCellType:RETableViewCellTypeMiddle];
[self.accessoriesSection.style setBackgroundImage:[[UIImage imageNamed:@"Last_Alt"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)]
                                      forCellType:RETableViewCellTypeLast];
[self.accessoriesSection.style setBackgroundImage:[[UIImage imageNamed:@"Single_Alt"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)]
                                      forCellType:RETableViewCellTypeSingle];

Contact

Roman Efimov

License

RETableViewManager is available under the MIT license.

Copyright © 2013 Roman Efimov.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

retableviewmanager's People

Contributors

astephensen avatar bhavya-kothari avatar cbess avatar daylen avatar dlo avatar fastred avatar guoxj avatar icanzilb avatar jdelaune avatar jhogervorst avatar jlnr avatar kliffy avatar marthinfreij avatar max-horvath avatar mrdaios avatar orthographic-pedant avatar paultran avatar romaonthego avatar rudensm avatar shmidt avatar skrew avatar supery avatar tasomaniac avatar unixo avatar xbeg9 avatar xingheng avatar yin8086 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

retableviewmanager's Issues

Easy way to change the Apple cell style

I wanted to set the cell style of my cells (e.g. UITableViewCellStyleValue1, UITableViewCellStyleValue2)

As far as I found out the only easy way to do that is to subclass ReTableViewItem, override the initializer and set the style there.

- (id)initWithTitle:(NSString *)title
      accessoryType:(UITableViewCellAccessoryType)accessoryType
   selectionHandler:(void (^)(RETableViewItem *))selectionHandler
accessoryButtonTapHandler:(void (^)(RETableViewItem *))accessoryButtonTapHandler
{
    if ((self = [super initWithTitle:title
                                    accessoryType:accessoryType
                                 selectionHandler:selectionHandler
           accessoryButtonTapHandler:accessoryButtonTapHandler])) {
        self.style = UITableViewCellStyleValue1;
    }
    return self;
}

Wouldn't it be better to set it like this from outside without the requirement to subclass:

[GCTournamentItem setDefaultCellStyle:UITableViewCellStyleValue1];

What do you think?

Table style

Hi Roman.

I have the following scenario:
I set up a table with 3 RERadioItems
In - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
I set cell.alpha = .75;
To make the table background visible through the cells.
Everything looks good until I select an option for one of the RERadioItems. When the table is updated in
[item reloadRowWithAnimation:UITableViewRowAnimationNone];
The cells loose the alpha setting.

Is there a way to prevent that?

clear button on text field not supported?

I have a RETextItem for which I'd like to enable the clear button (small cross at the right of the field).

It seems like setting this has no effect:

RETableViewTextCell* cell;
cell = (RETableViewTextCell*) [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
cell.textField.clearButtonMode = UITextFieldViewModeAlways;

I haven't tested on iOS 6, only on iOS 7, so it might be an SDK issue...

What's your thoughts?

Thanks,

Multiple RELongTextItem placeholders get mixed

If you add a few more RELongTextItems to your example,
then when you scroll table up-down you 'll see placeholder text will "jump" to wrong cells:

self.longTextItem = [RELongTextItem itemWithValue:nil placeholder:@"Multiline text field"];
self.longTextItem.cellHeight = 88;

RELongTextItem *longTextItem2 = [RELongTextItem itemWithValue:nil placeholder:@"Multiline text field2"];
longTextItem2.cellHeight = 88;

RELongTextItem *longTextItem3 = [RELongTextItem itemWithValue:nil placeholder:@"Multiline text field3"];
longTextItem3.cellHeight = 88;
[section addItem:longTextItem2];
[section addItem:longTextItem3];

RENumberItem for simple integer or float

I'm racking my brain trying to figure out how to get RENumberItem to play nice with a simple integer or float that isn't necessarily formatted. Ie. if I want to let a user input a quantity and cost field which doesn't fit any particular format restricted by character length. Looking through the code, the format seems to not use a regex, so how would I go about doing that?

allowsSelectionDuringEditing

Can you please implement allowsSelectionDuringEditing property?
Currently it's not possible to select cell in edit mode.

cellDidLoad get called twice

in the RETableViewManager.m Line 211 and Line 215, it will load the cell,
so, Line 201 get called Twice. it looks like a bug here.
thanks

[BUG] cellDidLoad never get call, if using storyboard

I noticed that you have some code like this in RETableViewManager:

RETableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
    cell = [[cellClass alloc] initWithStyle:cellStyle reuseIdentifier:cellIdentifier];
    ...
    [cell cellDidLoad];
    ...
}

Because [tableView dequeueReusableCellWithIdentifier:cellIdentifier] will never return nil if using storyboard. [cell cellDidLoad] will never get call

However, I have no idea how to fix it. Maybe you could move [cell cellDidLoad] to init method.

if you have any idea, please let me know. thx

Credit Card not showing additional fields

In running the example application, the credit card info (e.g. expiration date, cvv) are not displayed (nor editable).

Is there some configuration / mode I am missing?

Date picker pops up when scrolling a table view

Issue reproducible with the RETableViewManager Example project.

  1. Tap on the date/time form item to see the date picker.
  2. Tap done without changing.
  3. Now scroll the table view down a bit

RESULT: after scrolling the date picker shows up again for the previous date field.

EXPECTED: after clicking "done" on the date picker, the date field form item should no longer prompt for entry after scrolling

Custom inputAccessoryView on UITextView

Hi @romaonthego,
there is a way to customize the inputAccessoryView of UITextView?
I want to create new buttons (or may even replace) the UIToolbar used in inputAccessoryView.
In my app, has a field that I want to give the user the possibility to have additional functions to the standard keyboard on the iPad.

Best regards,
Edson Pieczarka Jr

Update pod

Can you please update pod?
Current version doesn't include onChange method for REPickerItem.

Assertion failure in -[RETableViewManager registerClass:forCellWithReuseIdentifier:],

Hi,

I use RETableViewManager in one of my projet. It worked like a charm, but now it crashes everytime I use it.
I installed the latest version using pods (1.2.6).

This is the error I got:

2013-09-09 08:03:11.448 MyProject[23377:907] *** Assertion failure in -[RETableViewManager registerClass:forCellWithReuseIdentifier:], /Users/axel/Dropbox/Developer/MyProject/MyProjct/Pods/RETableViewManager/RETableViewManager/RETableViewManager.m:121

2013-09-09 08:09:58.966 MyProject[23377:907] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Item class 'RETableViewOptionCell' does not exist.'

*** First throw call stack:
(0x3ea2012 0x352ee7e 0x3ea1e78 0x1a2e665 0x2af2e9 0x2af78a 0x2af062 0x2aee33 0x92afb 0x23fd1c7 0x23fd232 0x23fd4da 0x24148e5 0x24149cb 0x2414c76 0x2414d71 0x241589b 0x24159b9 0x2412c15 0x242aa72 0x242ab2a 0x260a0e6 0x23db66a 0x23dc498 0x2609f44 0x26094ee 0x2405ee3 0x2406167 0x7eaf9 0x3542705 0x231f2c0 0x231f258 0x23e0021 0x23e057f 0x23df6e8 0x234ecef 0x234ef02 0x232cd4a 0x231e698 0x3807df9 0x3807ad0 0x3e17bf5 0x3e17962 0x3e48bb6 0x3e47f44 0x3e47e1b 0x38067e3 0x3806668 0x231bffc 0xcd89 0x46ed70d)
libc++abi.dylib: terminate called throwing an exception
(lldb)

If I uncomment self[@"RERadioItem"] = @"RETableViewOptionCell";, I get the same thing for the next line in registerDefaultClass.
I checked and rechecked, the files are present, and no bug when I build my projet.

Do you have any idea?

Thanks!

section style stopped working after update to 1.0.5

after updated my cocoapod to 1.0.5 this code stopped working:

    RETableViewSection *closeSection = [RETableViewSection section];
    closeSection.style = [self.manager.style copy];
    [closeSection.style setBackgroundImage:[[UIImage imageNamed:@"btnBg"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)]
                               forCellType:RETableViewCellTypeAny];
    [_manager addSection: closeSection];

I.e. the background image is not applied anymore to the section

Focus goes back to a date picker after going back from an enum selector

Issue reproducible with the RETableViewManager Example project, on the form screen, on the iPad/simulator:

  1. Tap on the Date/Time field
  2. Select a value, but instead of tapping "Done" - tap on the Radio or Multiple item
  3. Select a value on the enum picker screen

RESULT:
The form view shows up again, and the date picker shows up as well

EXPECTED:
Since the focus has been changed to the next field (Radio), date picker for the previous field should no longer pop up.

Example graphic files are actually in the pod

When I build my project with the dependency of RETableViewManager it copies the resources as well.
That means when I publish my app, the folder 'RETableViewManager.bundle' is included with the little images 'Card_Discover.png', etc.

I think it should only be included in the example project(s)

Keyboard bar does not change appearance

Right now the REActionBar is hard coded to have light appearance in initWithDelegate:

    if (!REDeviceIsUIKit7()) {
        self.translucent = YES;
        self.barStyle = UIBarStyleBlackTranslucent;
    }

Therefore when the keyboard changes appearance, the action bar is always light.

image

Looks like a bug to me. You can pass the keyboard appearance to the bar too and make them sync. Right?

Allow access to origin object

Hi,

Thanks for this wonderful library!

Would it be possible to access the basic instance from an item?

Here's my use case:

I use a RETextItem, and I'd like to be able to send it the becomeFirstResponder message upon viewDidAppear in my controller. But as a far as I understand it, the UITextField instance is not accessible from outside.

Am I missing something?

Thanks,
Jérémy

bug report: RETableViewItem,when the type is NSString,the - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath crash

details:
thanks your great work!
may be a bug here:
in RETableViewManager.m Line 540,

RETableViewItem *item = [section.items objectAtIndex:indexPath.row];

we got an item, but the item is probably a NSString.
so Line 547: item.editingStyle got crash.
a quick and dirty fix:
if ([item isKindOfClass:[NSString class]]) {
return UITableViewCellEditingStyleNone;
}

iOS7 with XCode 5 compile warnings

Hi Roman,

Just downloaded xcode 5 today and playing with it.

Unfortunately they deprecated some of usual function that we use such as sizeWithFont etc. so it will show compilation warning now.

screenshot

RETableViewOptionsController

Make a list with RETableViewOptionsController, a lot of options — 15 for ex.
Select a few cells, then scroll tableview down, so they will go offscreen.
Then scroll tableview up and you will see that checkmark accessories are gone or shows on a wrong cells.

iOS 5 support

Why are you not supporting iOS 5? Any significant concerns that caused do not support it? I am really like your way to manage tableView, but as for now 80% of iOS projects still support > iOS 5.0

UIViewController table doesn't slides up

I use RETableViewManager with UIViewController (because I need toolbar).
When I edit textItem which positioned at the bottom of the screen, tableView didn't slides up as it does in UITableViewController.

Is it any solution to fix this?

how can I comprehend this syntax?

When I navigate the source code , I came across this code in RETableViewManager.
since RETableViewManager is not a NSDictionary , why can you use like this self[@""] ??

  • (void)registerDefaultClasses
    {
    self[@"__NSCFConstantString"] = @"RETableViewCell";
    self[@"__NSCFString"] = @"RETableViewCell";
    self[@"NSString"] = @"RETableViewCell";
    self[@"RETableViewItem"] = @"RETableViewCell";
    self[@"RERadioItem"] = @"RETableViewOptionCell";
    self[@"REBoolItem"] = @"RETableViewBoolCell";
    self[@"RETextItem"] = @"RETableViewTextCell";
    self[@"RELongTextItem"] = @"RETableViewLongTextCell";
    self[@"RENumberItem"] = @"RETableViewNumberCell";
    self[@"REFloatItem"] = @"RETableViewFloatCell";
    self[@"REDateTimeItem"] = @"RETableViewDateTimeCell";
    self[@"RECreditCardItem"] = @"RETableViewCreditCardCell";
    self[@"REMultipleChoiceItem"] = @"RETableViewOptionCell";
    }

Standard cell and compose view

Hi Roman. I love your library but I see a fe issues.
#1 I can't find a way to add a text with a value (value on blue aligned to left and NOT editable) something like the style of the Date/Time cell.
#2 I have a Long Text Item in the bottom of my table (inside a view controller) and when the keyboard appears it hides the textview. Is there a builtin compose view I can push in the navigation to avoid this issue?

Please let me know if there's a way of doing any of those tasks with the current code or if I have to create my own classes (which I'll gladly add to your code if you like)

Feature Request. Read only cell with title and value.

Hi again Roman, thanks again for sharing such a great lib.

I stumbled upon a problem when you want to create a cell but you just want to show just information without user interaction.

While we can create custom cell (cool feature!) but this kind of case is quite common so it's better to have this one natively available in the library.

Here is how the cell look like, from the screenshot from apple settings.
See the Total Storage, Available, and some others cell.

screenshot

So the proposed solution probably we have a property called readOnly in RETextItem or entirely brand new item class.

"value" should be left aligned whenever "title" set to nil

Hello,

First, thank you for creating such great library 🍺 . Much better and cleaner that everyone does.

To make consistent appearance and code with RETextItem, these classes below need to be left aligned whenever title set to nil.

  • REDateTimeItem
  • RERadioItem
  • REMultipleChoiceItem

This is screenshot of the current situation because the appearance inconsistent, when we want to design a form with no title:
screenshot

Thank you

Custom Cells Not updating UIImageView

I have a custom view for users to select a profile pic. The cell uses an imageview and the SDWebImage package to load the UIImageView from a url, but the image never refreshes when its part of RETableViewManager. Is there something extra I need to trigger a cell refresh?

issue/feature request

Great project. Ran into a limitation on dynamic inserting additional long textfield cells. For example, trying to create a form to allow list inputs via long textfield cell. Is this already possible, if not it will be nice to have to make it complete.

Previous selection in radio group not deselecting

I have a radio item with two options (copied mostly from the sample project). When I select the other item, both appear checked briefly before the view pops from the navigation stack. This is not elegant and potentially confusing.

Moreover, the controller object is not accessible from the completion callback as it won't have been assigned by the time it is captured. I'd suggest passing the controller as a parameter to the completion callback.

Finally, even if I do capture this reference, reloading the table doesn't seem to clear the checkbox of the previous item.

RENumberItem as first item causes problem with placeholder

Love this!

But I have a simple table with three items in the section. If the first item happens to be a RENumberItem, the position of the text entry control is placed over the label of the cell rather than to the right.

Making the first item a RETextItem, the following RENumberItems position correctly.

add/edit cell after viewDidLoad?

Hello,

I'm downloading some data from my server and i'd like to fill cells with them, but i was only able to add values to cells at viewDidLoad. Is it possible to add/edit cell's values after that?

Thank you so much for the AMAZING work!

Set First Responder

It would be cool if there was some way of setting a textitem to have the first responder set to it when the tableview loads.

Please support interface builder

There are some code in RETableViewManager.m
NSString *cellIdentifier = [NSString stringWithFormat:@"RETableViewManager_%@_%i", [item class], cellStyle];

RETableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

Because you use a custom cell identifier, it can't automatic alloc new cell from interface build,(storyboard or nib files).

I suggest that you can add a property cellIDentifier to RETableviewItem, and we can set it same as we set in IB, so that it can automatic alloc new cell from interface build.

REDateTimeItem doesn't honor presence validators

Hello, the problem is just like the title.

So for example you have code like this, it won't show up as errors, even tough the birthdate value is nil in self.manager.errors

self.birthdateItem = [REDateTimeItem itemWithTitle:nil value:nil placeholder:NSLocalizedString(@"Birth Date", nil) format:@"MMM dd, yyyy" datePickerMode:UIDatePickerModeDate];

self.birthdateItem.name = NSLocalizedString(@"Birth Date", nil);
self.birthdateItem.validators = @[@"presence"];

Thanks

Item value doesn't match the entered text

Hello guys!

First I'd like to thank you for your great work on this lib. It's truly one of the best I've ever used. Then right to the point, the item value I'm trying to get doesn't match the actual entered text. Below is the code I'm using:

// Add a section
//
RETableViewSection *section = [RETableViewSection sectionWithHeaderTitle:@"About you"];
[self.manager addSection:section];
self.sectionAboutYou = section;


// Display Name
//
RETextItem *displayName = [RETextItem itemWithTitle:@"Display name" value:[self.profile.displayName copy] placeholder:@"Your name"];
displayName.name = @"Display name";
displayName.validators = @[@"presence"];
displayName.autocapitalizationType = UITextAutocapitalizationTypeWords;
self.displayNameItem = displayName;


// Bio
//
RELongTextItem *bioItem = [RELongTextItem itemWithValue:[self.profile.bio copy] placeholder:@"Bio (140 characters max)"];
bioItem.autocapitalizationType = UITextAutocapitalizationTypeSentences;
bioItem.name = @"Bio";
bioItem.validators = @[[RELengthValidator validatorWithParameters:@{ @"min": @0, @"max": @140}]];
bioItem.cellHeight = 88;
self.bioItem = bioItem;


[section addItem:self.displayNameItem];
[section addItem:self.bioItem];
[section addItem:self.genderItem];

My issue is that when I do self.bioItem.value I get the original value and not the newly modified one.

It's probably something I missed in the documentation but could you help me out here?

Thanks!

Email cell

Trying to make e-mail cell with this code:

    RETextItem *email = [RETextItem itemWithTitle:NSLocalizedString(@"E-mail", nil) accessoryType:UITableViewCellAccessoryNone selectionHandler:^(RETableViewItem *item) {
        NSLog(@"Email sending");
        if ([MFMailComposeViewController canSendMail]) {
            MFMailComposeViewController *composeViewController =       [[MFMailComposeViewController alloc] init];
            [composeViewController setMailComposeDelegate:self];
            [composeViewController setToRecipients:@[item.value]];
            [composeViewController setSubject:@"example subject"];
            [self presentViewController:composeViewController animated:YES completion:nil];
        }
    }];
    email.onEndEditing = ^(RETextItem *item){
        NSLog(@"Email End editing");
        weakSelf.person.email = item.value;
        [weakSelf.person.managedObjectContext MR_saveToPersistentStoreAndWait];
    };

And have two problems:

  1. how to get textField.text inside selectionHandler
  2. I want to show keyboard only user taps on keyboard, not on selection.
    Is that possible?

RERadioItem selection doesn't trigger KVO

When a row is selected in the RETableViewOptionsController it is set as the new value of the RERadioItem that created the controller. So far so good.

If I read the value of that radio item after it has been set, the value is there.

But unfortunately, the updated value doesn't trigger KVO or, for that matter, a signal in ReactiveCocoa.

But looking at the code, I don't understand why this is the case.

RERadioItem * __weak item = (RERadioItem *)weakSelf.item;
item.value = selectedItem.title;
if (weakSelf.completionHandler)
    weakSelf.completionHandler();

Seems right to me.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.