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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值