The TWTRComposer class presents a view to the user to compose Tweets. It provides methods to optionally configure the contents of the Tweet composition prior to presenting it.
Compose TweetsThe
|
ユーザーにcomposer を表示する前に中身を初期化することができます。ツイートを設定するメソッドではBoolean型の値を戻り値として返します。; 既にcomposer が表示されている場合はNOを返します。 The completion handler has a single parameter which you can use to determine the result of the Tweet composition.
// Objective-C
TWTRComposer *composer = [[TWTRComposer alloc] init];
[composer setText:@"just setting up my Fabric"];
[composer setImage:[UIImage imageNamed:@"fabric"]];
[composer showWithCompletion:^(TWTRComposerResult result) {
if (result == TWTRComposerResultCancelled) {
NSLog(@"Tweet composition cancelled");
}
else {
NSLog(@"Sending Tweet!");
}
}];
// Swift
let composer = TWTRComposer()
composer.setText("just setting up my Fabric")
composer.setImage(UIImage(named: "fabric"))
composer.showWithCompletion { (result) -> Void in
if (result == TWTRComposerResult.Cancelled) {
println("Tweet composition cancelled")
}
else {
println("Sending tweet!")
}
}
注意
一度TWTRComposerのインスタンスが表示されると、それは再利用できません; ユーザーへ表示する度に毎回TWTRComposerのインスタンスを新規に作成しなければなりません。
注意
TWTRComposerrelies on the existence of a local Twitter account from the Accounts.framework. If no account exists, attempting to show the composer will prompt the user to go to Settings and add a Twitter account.
Presenting & Configuring the ComposerYou can set the initial content before presenting the composer to the user. Methods that set the content of a Tweet return a Boolean value; they return NO if the composer has already been presented. The completion handler has a single parameter which you can use to determine the result of the Tweet composition.
// Objective-C
TWTRComposer *composer = [[TWTRComposer alloc] init];
[composer setText:@"just setting up my Fabric"];
[composer setImage:[UIImage imageNamed:@"fabric"]];
[composer showWithCompletion:^(TWTRComposerResult result) {
if (result == TWTRComposerResultCancelled) {
NSLog(@"Tweet composition cancelled");
}
else {
NSLog(@"Sending Tweet!");
}
}];
// Swift
let composer = TWTRComposer()
composer.setText("just setting up my Fabric")
composer.setImage(UIImage(named: "fabric"))
composer.showWithCompletion { (result) -> Void in
if (result == TWTRComposerResult.Cancelled) {
println("Tweet composition cancelled")
}
else {
println("Sending tweet!")
}
}
|