Giter VIP home page Giter VIP logo

benno26 / base-ios-view-controllers Goto Github PK

View Code? Open in Web Editor NEW

This project forked from javisoto/base-ios-view-controllers

0.0 2.0 0.0 241 KB

Convenient base VCs for all your iPhone projects if you, like me, like writing less code. Allows to very easily create controllers with table views, controllers to show data from core data, adjusting the view with the keyboard easily and automatically, and more.

Home Page: http://javisoto.github.com/Base-iOS-View-Controllers

base-ios-view-controllers's Introduction

#Components

JSBaseViewController
JSBaseTableViewController
JSBaseCoreDataTableViewController
JSBaseTableViewCell

#Highlights

  • Adjusting your view automatically along with the keyboard.
  • Stick a view (like a textfield) on top of the keyboard.
  • Progress HUD showing / hiding in all your View Controllers.
  • Automatic cell nibs instantiation. Just code what is important.
  • Pull to refresh in one line of code.
  • Very easily implement tables that show data from Core Data.

#Features

- One generic method to construct your controllers:

Forget about implementing the right - initWith, awakeFromNib... just implement

- (void)setUp;

and be sure it will be called once in all cases.

- Easy way to show / hide a flexible progress HUD

Very handy for when you make long-running requests from any view controller.

- (void)showWaitView;
- (void)showWaitViewAndDimScreen;
- (void)showWaitViewWithMessage:(NSString*)message;
- (void)hideWaitView;
- (void)hideWaitViewWithSuccessMessage:(NSString *)message;
- (void)hideWaitViewWithErrorMessage:(NSString *)message;

- Implement table views with very little code:

Forget about dealing with nib loading, cell reusing, etc. Just set the name of the nib file that corresponds to the cell that the table will use in the setUp method like this:

- (void)setUp
{
	self.cellNibName = @"MyCellNibFileName";
}

and than you can just implement this method to make the necessary adjustments to the cell (which you can cast to your own UITableViewCell subclass):

- (UITableViewCell *)tableView:(UITableView *)tv configureCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath;

Only requirement is that your cell inherits from JSBaseTableViewCell.

- Add pull-to-refresh to you tables with one like of code:

Just set

self.tableHasPullToRefresh = YES;

in your setUp method. And then use these two methods:

/* Implement this method to respond to drag to refresh events */
- (void)reloadTableViewDataSource;
/* Call this method when the drag to refresh load has finished */
- (void)doneLoadingTableViewData;

- Implement infinite scrolling in you table views:

Just set:

self.tableHasInfiniteScrolling = YES;

And you will be called to this method:

- (void)loadMoreItemsAfterTheLastOne;

- Automatically have your view adjusted when the keyboard appears / disappears:

Just by calling

[self registerForKeyboardNotifications];

in your setUp method. If it's a regular view controller, you can implement

- (void)viewWillAdjustForKeyboardHidden:(BOOL)keyboardHidden keyboardHeight:(CGFloat)keyboardHeight;

which will be called inside an animation block that goes along with the keyboard. If it's a Table View Controller, the table will automatically adjust. if you want to provide custom behaviour, you can implement

- (void)tableViewWillBeResizedToAdjustForKeyboardHidden:(BOOL)keyboardHidden keyboardHeight:(CGFloat)keyboardHeight;

which will be called inside the animation block.

- Have a view stick on top of the keyboard and animate with it:

(very convenient for typical chat / comment views). Just implement the method:

- (UIView *)keyboardAuxView;

and return the view that you want to stay on top of the keyboard.

- Implement tables that show data from Core Data with very little code:

(and that are automatically refreshed with changes in them). Inherit from JSBaseCoreDataTableViewController and implement:

- (NSFetchRequest *)fetchRequest;

to return an NSFetchRequest object corresponding to the query you want to perform. And then implement this other method that will be called on you:

- (UITableViewCell *)tableView:(UITableView *)tv configureCell:(UITableViewCell *)cell forManagedObject:(NSManagedObject *)object;

- Have all your cells automatically be correctly reused even if you forget to set the reuse identifier in Interface Builder:

For this you only need to make your cell classes inherit from JSBaseTableViewCell.

#Submodules

- JSProgressHUD: https://github.com/JaviSoto/JSProgressHUD
- EGOTableViewPullRefresh: https://github.com/enormego/EGOTableViewPullRefresh

#Installation

First clone the repository:

$ git clone [email protected]:JaviSoto/Base-iOS-View-Controllers.git
$ cd Base-iOS-View-Controllers
$ git submodule init
$ git submodule update

Second. Drag the BaseControllers folder to your Xcode project. And remove the unneeded files (like the EGOTableViewPullRefresh sample project)

Third. Link against these frameworks:

CoreData
QuartzCore

Fourth. (Optional) Modify the method - (NSManagedObjectContext *)managedObjectContext in JSBaseViewController by adding the needed logic to create a NSManagedObjectContext passing your NSPersistantStoreCordinator (ONLY IF YOU WANT TO USE CORE DATA).

#Credits

Thanks to Oriol Blanc, because a lot of this is thanks to him :)

Bitdeli Badge

base-ios-view-controllers's People

Contributors

bitdeli-chef avatar javisoto avatar

Watchers

 avatar  avatar

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.