UIViewController subclass using SDSegmentedControl and View Controller Containment API's to switch between child view controllers
(click to download a video of the controller in action).
- Uses View Controller Containment API's to display a list of view controllers
- Uses the excellent SDSegmentedControl to display a view controller switcher at the top
- Can be used with code and Interface Builder
- Can be used with Autolayout
- When using
UITableView
's orUICollectionView
's automatically adjustscontentInset
andscrollIndicatorInsets
to accomodate for segmented control - Allows for a delegate to be notified when the selected view controller will / did change
- ARC
- Xcode 4.4+ (needed for modern Objective-C syntax)
- iOS 6+
Add pod 'NGSegmentedViewController'
to your Podfile.
Important note if your project doesn't use ARC: you must add the -fobjc-arc
compiler flag to NGSegmentedViewController.m
in Target Settings > Build Phases > Compile Sources.
- Drag the
NGSegmentedViewController/NGSegmentedViewController
folder into your project - Download SDSegmentedControl and drag
SDSegmentedControl.{h,m}
into your project - Add the QuartzCore framework to your project
- You might need to change the
#import <SDSegmentedControl/SDSegmentedControl.h>
inNGSegmentedViewController.h
to#import "SDSegmentedControl.h"
I have added two demos. NGSegmentedViewController example
uses code to set up a segmented view controller and NGSegmentedViewController IB example
uses Interface Builder to set one up.
As this is my first open source iOS control, it is possible that I made mistakes. Furthermore, I only implemented features that seemed useful to me. If you find any errors or want extra features, feel free to fork this project and sent in a Pull Request.
Instantiate a segmented view controller with initWithViewControllers:
or initWithViewControllers:titles:
.
When using Interface Builder, create a subclass and overwrite awakeFromNib
to call setupWithViewControllers:
or setupWithViewControllers:titles:
.
All source code is licensed under the MIT-License.
Copyright 2013 Nicky Gerritsen.
- Nicky Gerritsen ([email protected])