读书人

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

发布时间: 2013-02-03 12:33:31 作者: rapoo

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

集成Twitter的功能到你的应用中


把Twitter的功能集成到IOS应用中去

使用Twitter框架库包


#import <Twitter/Twitter.h>

@property(nonatomic,strong)TWTweetComposeViewController *twitterController;

@synthesize twitterController;


twitterController = [[TWTweetComposeViewControlleralloc]init];

__weakViewController *weakSelf = self;

[twitterControllersetCompletionHandler:^(TWTweetComposeViewControllerResult result){

ViewController *strongSelf = weakSelf;

switch (result) {

caseTWTweetComposeViewControllerResultDone:

/*Teh Tweet was submitted successfully. Will be dismissed automatically*/

break;

caseTWTweetComposeViewControllerResultCancelled:{

if(strongSelf != nil){

[strongSelf.twitterControllerdismissModalViewControllerAnimated:YES];

}

break;

}

}

}];

NSString *text =@"Anthony Robbins at Unleash the Power Within(UPW)in Lindon";

[twitterControllersetInitialText:text];

UIImage *anthonyRobbins = [UIImageimageNamed:@"img.jpg"];

[twitterControlleraddImage:anthonyRobbins];

NSURL *url = [NSURLURLWithString:@"http://www.tonyrobbins.com"];

[twitterControlleraddURL:url];

[self.navigationControllerpresentModalViewController:twitterControlleranimated:YES];


TWTweetComposeViewControllerResultCancelled 这个方法是当前用户在进入Twitter界面的时候,然后点击了取消的事件。

TWTweetComposeViewControllerResultDone 这个方法是进入Twitter界面,然后正常的发送了界面中的信息。


读书人网 >操作系统

热点推荐