Giter Site home page Giter Site logo

samback / cksidebarcontroller Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jaykz52/cksidebarcontroller

0.0 2.0 0.0 529 KB

CKSideBarController is a UITabBarController-like UIViewController for iPad. Inspired by Twitter for iPad, as well as my own work.

cksidebarcontroller's Introduction

CKSideBarController

CKSideBarController is a UITabBarController-like UIViewController for iPad. It's inspired by Twitter for iPad, as well as my own work. Take a look at the example app included in the source code to see what you can do with CKSideBarController, see the below walkthrough, or dig into the source code!

Screenshot

Dependencies

To use CKSideBarViewController in your project, in addition to UIKit.framework and Foundation.framework you'll need to link against the following frameworks:

  • CoreGraphics.framework
  • QuartzCore.framework

Adding CKSideBarController to your XCode project

CocoaPods outstanding, the easiest way to integrate CKSideBarController into your project is to clone the repo and add all of the items under the Source directory. This includes a few image resources used by CKSideBarController.

CKSideBarController uses ARC, so for non-ARC projects, you'll want to add the f-objc-arc linker flag for CKSideBarController.m and CKSideBarItem.m.

Using CKSideBarController

CKSideBarController, like UITabBarController and UISplitViewController, works best as the rootViewController of your application:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.

    self.barController = [[CKSideBarController alloc] init];
    self.window.rootViewController = self.barController;

    [self.window makeKeyAndVisible];

    return YES;
}

In order to provide content for the CKSideBarController, you assign an array of UIViewControllers to the viewControllers property of your CKSideBarController instance:

- (void)someMethod {
    self.barController.viewControllers = @[
      [[FirstViewController alloc] init],
      [[SecondViewController alloc] init],
      [[ThirdViewController alloc] init]
    ];
}

We can configure how each UIViewController managed by the bar controller is displayed by setting by manipulating each's sideBarItem. You'll need to import the CKSideBarController.h file in order to see the sideBarItem property.

#import "CKSideBarController.m"

// ...

@implementation FirstViewController

- (id)init {
    self = [super init];
    if (self) {
        self.sideBarItem.title = @"First";
        self.sideBarItem.image = [UIImage imageNamed:@"first.png"];
        self.sideBarItem.isGlowing = YES;

        // do something awesome...
    }
    return self;
}

// ...

@end

For more fine-grained control over the CKSideBarController's behavior is via the CKSideBarController's delegate. All methods in the CKSideBarControllerDelegate are optional, so implement the ones important to you. Be sure to set the delegate property of your CKSideBarController to the appropriate object.

#pragma mark - CKSideBarControllerDelegate

// Remember sideBarController.delegate = self !!!

- (BOOL)sideBarController:(CKSideBarController *)sideBarController shouldSelectViewController:(UIViewController *)viewController {
    return NO;  // can't touch this
}

- (void)sideBarController:(CKSideBarController *)sideBarController didSelectViewController:(UIViewController *)viewController {
    NSLog(@"viewController %@ selected!", viewController);
}

Lastly, if you import the CKSideBarController.h, you can access the CKSideBarController ancestor of any UIViewController (if one exists) via the sideBarController property mixed into the UIViewCOntroller class. This is much like UINavigationController and UITabBarController. If there is no CKSideBarController ancestor, the property will simply be nil.

Customizing

Currently, the only way to customize the look and feel of CKSideBarController is to alter the source files. The view code is fairly readable, searching on UIFont, UIColor, and UIImage should give you a good starting point.

Currently, Updating a UIViewController's sideBarItem does not trigger a UI refresh. As a stop-gap, you can call the refresh method on the CKSideBarController to manually trigger a UI refresh.

Contributing

Automatic UI Refreshing on sideBarItem updates does not currently happen. Additionally, it would be nice to provide UI customization points to help match the look-and-feel of the app integrating the controller.

License (MIT)

Copyright (c) 2012 Jason Kozemczak

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.

cksidebarcontroller's People

Contributors

jaykz52 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.