Skip to content

Instantly share code, notes, and snippets.

@shepting
Created January 26, 2016 02:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shepting/292140c8cc68b04ce802 to your computer and use it in GitHub Desktop.
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.
#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
@shepting
Copy link
Author

screenshot 2016-01-25 18 06 26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment