Commit 9d9cd5b04504f0eed3148c507687e28c9f4bfe5c

Authored by bryan ago
1 parent 0e3f5792bf
Exists in master

Implementation the Twitter Composer Example

Showing 6 changed files with 70 additions and 7 deletions Side-by-side Diff

TwitterKitExample.xcodeproj/project.pbxproj View file @ 9d9cd5b
... ... @@ -8,6 +8,7 @@
8 8  
9 9 /* Begin PBXBuildFile section */
10 10 974C68101C16A5FA00A6B9A3 /* TWTimelineViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 974C680F1C16A5FA00A6B9A3 /* TWTimelineViewController.m */; };
  11 + 974C68131C16BD4900A6B9A3 /* TWComposeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 974C68121C16BD4900A6B9A3 /* TWComposeViewController.m */; };
11 12 9759727A1C1677C200B36305 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 975972791C1677C200B36305 /* main.m */; };
12 13 9759727D1C1677C200B36305 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9759727C1C1677C200B36305 /* AppDelegate.m */; };
13 14 975972801C1677C200B36305 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9759727F1C1677C200B36305 /* ViewController.m */; };
... ... @@ -43,6 +44,8 @@
43 44 /* Begin PBXFileReference section */
44 45 974C680E1C16A5ED00A6B9A3 /* TWTimelineViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TWTimelineViewController.h; sourceTree = "<group>"; };
45 46 974C680F1C16A5FA00A6B9A3 /* TWTimelineViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TWTimelineViewController.m; sourceTree = "<group>"; };
  47 + 974C68111C16BD3F00A6B9A3 /* TWComposeViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TWComposeViewController.h; sourceTree = "<group>"; };
  48 + 974C68121C16BD4900A6B9A3 /* TWComposeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TWComposeViewController.m; sourceTree = "<group>"; };
46 49 975972751C1677C200B36305 /* TwitterKitExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TwitterKitExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
47 50 975972791C1677C200B36305 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
48 51 9759727B1C1677C200B36305 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
... ... @@ -135,6 +138,8 @@
135 138 97D40CD71C168951004C1527 /* TWListViewController.m */,
136 139 974C680E1C16A5ED00A6B9A3 /* TWTimelineViewController.h */,
137 140 974C680F1C16A5FA00A6B9A3 /* TWTimelineViewController.m */,
  141 + 974C68111C16BD3F00A6B9A3 /* TWComposeViewController.h */,
  142 + 974C68121C16BD4900A6B9A3 /* TWComposeViewController.m */,
138 143 );
139 144 path = TwitterKitExample;
140 145 sourceTree = "<group>";
... ... @@ -313,6 +318,7 @@
313 318 isa = PBXSourcesBuildPhase;
314 319 buildActionMask = 2147483647;
315 320 files = (
  321 + 974C68131C16BD4900A6B9A3 /* TWComposeViewController.m in Sources */,
316 322 975972801C1677C200B36305 /* ViewController.m in Sources */,
317 323 9759727D1C1677C200B36305 /* AppDelegate.m in Sources */,
318 324 9759727A1C1677C200B36305 /* main.m in Sources */,
TwitterKitExample/TWComposeViewController.h View file @ 9d9cd5b
  1 +//
  2 +// TWComposeViewController.h
  3 +// TwitterKitExample
  4 +//
  5 +// Created by DongSoo Lee on 2015. 12. 8..
  6 +// Copyright © 2015년 DongSoo Lee. All rights reserved.
  7 +//
  8 +
  9 +#ifndef TWComposeViewController_h
  10 +#define TWComposeViewController_h
  11 +
  12 +#import <UIKit/UIKit.h>
  13 +
  14 +@interface TWComposeViewController : UIViewController
  15 +
  16 +@end
  17 +
  18 +
  19 +#endif /* TWComposeViewController_h */
TwitterKitExample/TWComposeViewController.m View file @ 9d9cd5b
  1 +//
  2 +// TWComposeViewController.m
  3 +// TwitterKitExample
  4 +//
  5 +// Created by DongSoo Lee on 2015. 12. 8..
  6 +// Copyright © 2015년 DongSoo Lee. All rights reserved.
  7 +//
  8 +
  9 +#import "TWComposeViewController.h"
  10 +#import <TwitterKit/TwitterKit.h>
  11 +
  12 +@implementation TWComposeViewController
  13 +
  14 +- (void)viewDidLoad {
  15 + [super viewDidLoad];
  16 +
  17 + self.title = @"트위터 작성";
  18 +
  19 + TWTRComposer *composer = [[TWTRComposer alloc] init];
  20 +
  21 + [composer setText:@"just setting up my Fabric"];
  22 + [composer setImage:[UIImage imageNamed:@"fabric"]];
  23 +
  24 + [composer showFromViewController:self completion:^(TWTRComposerResult result) {
  25 + if (result == TWTRComposerResultCancelled) {
  26 + NSLog(@"Tweet composition cancelled");
  27 + } else {
  28 + NSLog(@"Sending Tweet!");
  29 + }
  30 + }];
  31 +}
  32 +
  33 +@end
TwitterKitExample/TWListViewController.m View file @ 9d9cd5b
... ... @@ -9,6 +9,7 @@
9 9 #import "TWListViewController.h"
10 10 #import <TwitterKit/TwitterKit.h>
11 11 #import "TWTimelineViewController.h"
  12 +#import "TWComposeViewController.h"
12 13  
13 14 @interface TWListViewController()
14 15  
... ... @@ -26,6 +27,8 @@
26 27  
27 28 self.edgesForExtendedLayout = UIRectEdgeNone;
28 29  
  30 + self.title = @"트위터 싱글뷰";
  31 +
29 32 TWTRTweetView *tweetView = [[TWTRTweetView alloc] init];
30 33 tweetView.showActionButtons = YES;
31 34  
32 35  
33 36  
34 37  
35 38  
... ... @@ -54,32 +57,31 @@
54 57 }
55 58 }];
56 59  
57   - UIImage *image = [UIImage imageNamed:@"TwitterKitResources.bundle/icn_close.png"];
  60 + UIImage *image = [UIImage imageNamed:@"TwitterKitResources.bundle/twtr-icn-logo.png"];
58 61 UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, image.size.width, image.size.height)];
59 62 [button setImage:image forState:UIControlStateNormal];
60 63 [button addTarget:self action:@selector(moveToWrite) forControlEvents:UIControlEventTouchUpInside];
61 64 UIBarButtonItem *temp = [[UIBarButtonItem alloc] initWithCustomView:button];
62 65  
63   - NSArray *rightItemArray = @[
64   - temp
65   - , [[UIBarButtonItem alloc] initWithTitle:@"타임라인" style:UIBarButtonItemStylePlain target:self action:@selector(moveToTimeline)]];
  66 + NSArray *rightItemArray = @[temp
  67 + , [[UIBarButtonItem alloc] initWithTitle:@"타임라인" style:UIBarButtonItemStylePlain target:self action:@selector(moveToTimeline)]];
66 68 [self.navigationItem setRightBarButtonItems:rightItemArray];
67 69  
68 70 }
69 71  
70 72 - (void) moveToTimeline {
71 73 TWTimelineViewController *vc = [[TWTimelineViewController alloc] init];
72   - [self.navigationController pushViewController:vc animated:NO];
  74 + [self.navigationController pushViewController:vc animated:YES];
73 75 }
74 76  
75 77 - (void) moveToWrite {
76   - TWTimelineViewController *vc = [[TWTimelineViewController alloc] init];
  78 + TWComposeViewController *vc = [[TWComposeViewController alloc] init];
77 79 [self.navigationController pushViewController:vc animated:YES];
78 80 }
79 81  
80 82 - (void) congifureTableView:(CGRect) frame {
81 83  
82   - self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, frame.origin.y+frame.size.height
  84 + self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, frame.origin.y+frame.size.height+50
83 85 , self.view.bounds.size.width, 300)];
84 86 [self.view addSubview:self.tableView];
85 87  
TwitterKitExample/TWTimelineViewController.m View file @ 9d9cd5b
... ... @@ -13,6 +13,8 @@
13 13 - (void) viewDidLoad {
14 14 [super viewDidLoad];
15 15  
  16 + self.title = @"트위터 타임라인";
  17 +
16 18 TWTRAPIClient *client = [[TWTRAPIClient alloc] init];
17 19 self.dataSource = [[TWTRUserTimelineDataSource alloc] initWithScreenName:@"fabric" APIClient:client];
18 20 // self.dataSource = [[TWTRSearchTimelineDataSource alloc] initWithSearchQuery:@"#fabricdev" APIClient:client];
TwitterKitExample/ViewController.m View file @ 9d9cd5b
... ... @@ -19,6 +19,7 @@
19 19 - (void)viewDidLoad {
20 20 [super viewDidLoad];
21 21 // Do any additional setup after loading the view, typically from a nib.
  22 + self.title = @"트위터 로그인";
22 23  
23 24 __weak typeof(self) wself = self;
24 25 TWTRLogInButton *loginButton = [TWTRLogInButton buttonWithLogInCompletion:^(TWTRSession * _Nullable session, NSError * _Nullable error) {