集成Twitter的功能到你的应用中
把Twitter的功能集成到IOS应用中去
使用Twitter框架库包
#import <Twitter/Twitter.h>
@property(nonatomic,strong)TWTweetComposeViewController *twitterController;
@synthesize twitterController;
twitterController = [[TWTweetComposeViewController alloc]init];
__weak ViewController *weakSelf = self;
[twitterController setCompletionHandler:^(TWTweetComposeViewControllerResult result){
ViewController *strongSelf = weakSelf;
switch (result) {
case TWTweetComposeViewControllerResultDone:
/*Teh Tweet was submitted successfully. Will be dismissed automatically*/
break;
case TWTweetComposeViewControllerResultCancelled:{
if(strongSelf != nil){
[strongSelf.twitterController dismissModalViewControllerAnimated:YES];
}
break;
}
}
}];
NSString *text = @"Anthony Robbins at Unleash the Power Within(UPW)in Lindon";
[twitterController setInitialText:text];
UIImage *anthonyRobbins = [UIImage imageNamed:@"img.jpg"];
[twitterController addImage:anthonyRobbins];
NSURL *url = [NSURL URLWithString:@"http://www.tonyrobbins.com"];
[twitterController addURL:url];
[self.navigationController presentModalViewController:twitterController animated:YES];
TWTweetComposeViewControllerResultCancelled 这个方法是当前用户在进入Twitter界面的时候,然后点击了取消的事件。
TWTweetComposeViewControllerResultDone 这个方法是进入Twitter界面,然后正常的发送了界面中的信息。