https://github.com/johnvuko/jtscrollviewcontroller
Create a ScrollViewController on iOS pragmatically using Auto Layout without a nib file.
https://github.com/johnvuko/jtscrollviewcontroller
Last synced: 11 months ago
JSON representation
Create a ScrollViewController on iOS pragmatically using Auto Layout without a nib file.
- Host: GitHub
- URL: https://github.com/johnvuko/jtscrollviewcontroller
- Owner: johnvuko
- License: mit
- Created: 2014-10-29T14:14:58.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-05-30T16:37:36.000Z (about 11 years ago)
- Last Synced: 2025-05-02T02:38:37.723Z (about 1 year ago)
- Language: Objective-C
- Homepage:
- Size: 268 KB
- Stars: 31
- Watchers: 6
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JTScrollViewController
[](https://travis-ci.org/jonathantribouharet/JTScrollViewController)



JTScrollViewController help you to create pragmatically a UIViewController with a UIScrollView which take all the space available using Auto Layout without using a nib file.
It creates all constraints required for your views.
## Installation
With [CocoaPods](http://cocoapods.org/), add this line to your Podfile.
pod 'JTScrollViewController', '~> 1.0'
## Usage
Create a controller which inherit from JTScrollViewController.
```objective-c
#import
#import
@interface MyViewController : JTScrollViewController
@end
```
Create your views in the `viewDidLoad` and call `configureConstraintsForSubviews` for create all constraints.
You can call `addVerticalSpacingForStatusBar` when you don't want the scrollView go under the status bar.
Each views are displayed in the orders they were added to `contentView`.
You have to set the height of each views by setting the height of their frames.
You can also add a space between each views by settings `y` property of their frames.
```objective-c
#import "MyViewController.h"
@implementation MyViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Add all your views to self.contentView
// Do your stuff...
{
CGFloat spaceFromTop = 30.;
UITextField *textField = [UITextField alloc] initWithFrame:CGRectMake(0, spaceFromTop, 0, 45)];
[self.contentView addSubview:textField];
}
{
UITextField *textField = [UITextField alloc] initWithFrame:CGRectMake(0, 5, 0, 45)];
[self.contentView addSubview:textField];
}
{
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 10, 0, 50)];
[self.contentView addSubview:button];
}
// Add vertical space (22px) for the status bar
// Use this when you don't have a navigation bar and you don't want the scroll go under the status bar
[self addVerticalSpacingForStatusBar:YES];
// Call configureConstraintsForSubviews for create all constraints
[self configureConstraintsForSubviews];
}
```
## Requirements
- iOS 7 or higher
- Automatic Reference Counting (ARC)
## Author
- [Jonathan Tribouharet](https://github.com/jonathantribouharet) ([@johntribouharet](https://twitter.com/johntribouharet))
## License
JTScrollViewController is released under the MIT license. See the LICENSE file for more info.