DTFormMenuController 0.1.8

DTFormMenuController 0.1.8

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Mar 2015

Maintained by Daniel Thengvall.



  • By
  • DTHENG

Usage

  • Start by creating a new class that extends the DTFormViewController:

ViewController.h view file

#import "DTFormViewController.h"

@interface ViewController : DTFormViewController

@end
  • Then in the implementation file you'll initialize the form with its "objects":

ViewController.m view file

- (void)viewDidLoad {
    [super viewDidLoad];

    [super setFormObjects:@[

        // Array of objects that extend DTBaseFormObject

    ]];
}

NOTE you dont have to execute setFormObjects in the viewDidLoad method, it can be called from anywhere.

  • Now that you have your view controller setup you will need to open or create a Main.storyboard file.
  • In the Main storyboard add a new UICollectionViewController.
  • Find the new view controllers Identity inspector set the Custom Class and Storyboard ID fields to DTFormMenuViewController.
  • Now in the view controller's Collection View Flow Layout set the Min Spacing values to 0.
  • In the view controller set the UICollectionViewCell's Reusable Identifier to "content".
  • Form objects are any class that extends DTBaseFormObject.

ExampleTextInputFormObject.h view file

#import "DTBaseFormObject.h"

@interface ExampleTextInputFormObject : DTBaseFormObject

- (ExampleTextInputFormObject *)initWithPlaceholder:(NSString *)placeholderText onChanged:(void (^)(NSString *text))onChangedBehavior;

@end
  • In the implementation of the new class the only required override method is:

ExampleTextInputFormObject.m view file

- (UICollectionViewCell *)toCollectionViewCell:(UICollectionView *)collectionView :(NSIndexPath *)indexPath {

    UICollectionViewCell *exampleCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"example" forIndexPath:indexPath];

    // Customize cell

    return exampleCell;
}
  • Before we can run the code we'll need to add the ViewController to Main.storyboard.
  • In the Main storyboard add a new UICollectionViewController.
  • Find the new view controllers Identity inspector set the Custom Class and Storyboard ID fields to the name of your class.
  • Now in the view controller's Collection View Flow Layout set the Min Spacing values to 0.
  • In the view controller set the UICollectionViewCell's Reusable Identifier to "example".
  • Done!

Installation

DTFormMenuController is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'DTFormMenuController', '0.1.8'

Dont have a Podfile?

You can easily update your project to use CocoaPods:

  • Install the CocoaPods library:
sudo gem install cocoapods
  • Go to the directory where your .xcodeproj file is
  • Create a new file called Podfile
  • Update Podfile with:
platform :ios, deployment_target: '8.0'

pod 'DTFormMenuController', '0.1.8'
  • Now run this command:
pod install
  • From now on only open the .xcworkspace file in your project NOT .xcodeproj
  • Done!

Author

DTHENG, [email protected]

License

DTFormMenuController is available under the MIT license. See the LICENSE file for more info.