Skip to content

Instantly share code, notes, and snippets.

@robbdimitrov
Created May 13, 2016 13:17
Show Gist options
  • Save robbdimitrov/191b4bd1a86ad31962ee6e202007b6c4 to your computer and use it in GitHub Desktop.
Save robbdimitrov/191b4bd1a86ad31962ee6e202007b6c4 to your computer and use it in GitHub Desktop.
Twitter doesn't allow setting text in TWTRConposerViewControlller, which is used for app cards. This is a simple hack to do just that.
//
// CMTWTRConposerViewControlller.h
// ProtoSketch
//
// Created by Robert Dimitrov on 5/13/16.
// Copyright © 2016 Codemotion Ltd. All rights reserved.
//
#import <TwitterKit/TwitterKit.h>
@interface CMTWTRConposerViewControlller : TWTRComposerViewController
@property (nonatomic, readwrite, copy) NSString *tweetText;
@end
//
// CMTWTRConposerViewControlller.m
// ProtoSketch
//
// Created by Robert Dimitrov on 5/13/16.
// Copyright © 2016 Codemotion Ltd. All rights reserved.
//
#import "CMTWTRConposerViewControlller.h"
@implementation CMTWTRConposerViewControlller
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
for (UIView *subview in self.view.subviews) {
if ([subview respondsToSelector:@selector(textView)]) {
UITextView *textView = (UITextView *)[subview performSelector:@selector(textView)];
if ([textView isKindOfClass:[UITextView class]]) {
textView.text = self.tweetText;
break;
}
}
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment