`
yidongkaifa
  • 浏览: 4065836 次
文章分类
社区版块
存档分类
最新评论

IOS学习笔记(17)集成Twitter的功能

 
阅读更多

集成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界面,然后正常的发送了界面中的信息。


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics