Created
January 26, 2016 02:11
-
-
Save shepting/292140c8cc68b04ce802 to your computer and use it in GitHub Desktop.
Some users have requested a sample implementation to make a child viewcontroller showing a timeline of Tweets.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <TwitterKit/TwitterKit.h> | |
@implementation ViewController | |
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
self.view.backgroundColor = [UIColor lightGrayColor]; | |
// Standard TWTRTimelineViewController setup | |
TWTRUserTimelineDataSource *dataSource = [[TWTRUserTimelineDataSource alloc] initWithScreenName:@"StephenCurry30" APIClient:[[TWTRAPIClient alloc] init]]; | |
TWTRTimelineViewController *timelineViewController = [[TWTRTimelineViewController alloc] initWithDataSource:dataSource]; | |
// Standard parent-child view controller | |
[self addChildViewController:timelineViewController]; | |
[self.view addSubview:timelineViewController.view]; | |
[timelineViewController didMoveToParentViewController:self]; | |
// Standard sizing | |
timelineViewController.view.translatesAutoresizingMaskIntoConstraints = NO; | |
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-150-[timeline]-150-|" options:0 metrics:nil views:@{@"timeline": timelineViewController.view}]]; | |
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[timeline]|" options:0 metrics:nil views:@{@"timeline": timelineViewController.view}]]; | |
} | |
@end |
Author
shepting
commented
Jan 26, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment