Giter VIP home page Giter VIP logo

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

View Code? Open in Web Editor NEW
44.0 6.0 9.0 280 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

Objective-C 100.00%

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 then 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 esttorhe avatar javisoto avatar rcabamo 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

base-ios-view-controllers's Issues

Error in third tab

Break in JSBaseCoreDataTableViewController.m, line 85

2012-03-29 15:18:51.257 BaseiOSViewControllers-DemoProject[5227:b603] *** Terminating app due to uncaught exception 'NSObjectInaccessibleException', reason: 'This fetch request (0x5a97b90) was created with a string name (ToDo), and cannot respond to -entity until used by an NSManagedObjectContext'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x011e15a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x0158b313 objc_exception_throw + 44
    2   CoreData                            0x00e4868f -[NSFetchRequest entity] + 159
    3   CoreData                            0x00f297fb -[NSFetchedResultsController initWithFetchRequest:managedObjectContext:sectionNameKeyPath:cacheName:] + 763
    4   BaseiOSViewControllers-DemoProject  0x00002d62 -[JSBaseCoreDataTableViewController fetchedResultsController] + 290
    5   BaseiOSViewControllers-DemoProject  0x00002956 -[JSBaseCoreDataTableViewController viewDidLoad] + 102
    6   UIKit                               0x00247089 -[UIViewController view] + 179
    7   UIKit                               0x00259f54 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 120
    8   UIKit                               0x00258aaa -[UITabBarController transitionFromViewController:toViewController:] + 64
    9   UIKit                               0x0025a8a2 -[UITabBarController _setSelectedViewController:] + 263
    10  UIKit                               0x0025a711 -[UITabBarController _tabBarItemClicked:] + 352
    11  UIKit                               0x001974fd -[UIApplication sendAction:to:from:forEvent:] + 119
    12  UIKit                               0x00399ce6 -[UITabBar _sendAction:withEvent:] + 422
    13  UIKit                               0x001974fd -[UIApplication sendAction:to:from:forEvent:] + 119
    14  UIKit                               0x00227799 -[UIControl sendAction:to:forEvent:] + 67
    15  UIKit                               0x00229c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
    16  UIKit                               0x00227750 -[UIControl sendActionsForControlEvents:] + 49
    17  UIKit                               0x001974fd -[UIApplication sendAction:to:from:forEvent:] + 119
    18  UIKit                               0x00227799 -[UIControl sendAction:to:forEvent:] + 67
    19  UIKit                               0x00229c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
    20  UIKit                               0x002287d8 -[UIControl touchesEnded:withEvent:] + 458
    21  UIKit                               0x001bbded -[UIWindow _sendTouchesForEvent:] + 567
    22  UIKit                               0x0019cc37 -[UIApplication sendEvent:] + 447
    23  UIKit                               0x001a1f2e _UIApplicationHandleEvent + 7576
    24  GraphicsServices                    0x01c64992 PurpleEventCallback + 1550
    25  CoreFoundation                      0x011c2944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    26  CoreFoundation                      0x01122cf7 __CFRunLoopDoSource1 + 215
    27  CoreFoundation                      0x0111ff83 __CFRunLoopRun + 979
    28  CoreFoundation                      0x0111f840 CFRunLoopRunSpecific + 208
    29  CoreFoundation                      0x0111f761 CFRunLoopRunInMode + 97
    30  GraphicsServices                    0x01c631c4 GSEventRunModal + 217
    31  GraphicsServices                    0x01c63289 GSEventRun + 115
    32  UIKit                               0x001a5c93 UIApplicationMain + 1160
    33  BaseiOSViewControllers-DemoProject  0x00001e2a main + 170
    34  BaseiOSViewControllers-DemoProject  0x00001d75 start + 53
)

Problemas al importar las clases

Sigo los pasos de instalación al pie de la letra, cuando añado las clases al proyecto muestra algunos errores

  • 'JSProgressHUD.h' file not found
  • 'JSBaseCoreDataBackedTableViewController.h' file not found
  • Property 'shouldRasterize' cannot be found in forward class object 'CALayer *'
  • Property 'shouldRasterize' cannot be found in forward class object 'CALayer *'
  • Property 'rasterizationScale' cannot be found in forward class object 'CALayer *'

Parece ser que hay algún import con el nombre de una clase que no existe, si no te importa echarle un vistazo.

Mirandolo por encima me ha gustado mucho, todo muy bien estructurado y muy bien pensado, en cuanto solucione esos problemillas la pruebo a fondo.

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.