Translate

2013年4月22日 星期一

SLComposeViewController

參考1
參考2
參考中文網站

首先先加入Social.framework跟Accounts.framework

有三種可以使用

SLServiceTypeTwitter;
SLServiceTypeFacebook;
SLServiceTypeSinaWeibo;

分享facebook

SLComposeViewController *fbController=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) { SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result){ [fbController dismissViewControllerAnimated:YES completion:nil]; switch(result){ case SLComposeViewControllerResultCancelled: default: { NSLog(@"Cancelled....."); } break; case SLComposeViewControllerResultDone: { NSLog(@"Posted...."); } break; }}; [fbController addImage:[UIImage imageNamed:@"1.jpg"]]; [fbController setInitialText:@"Check out this article."]; [fbController addURL:[NSURL URLWithString:@"http://soulwithmobiletechnology.blogspot.com/"]]; [fbController setCompletionHandler:completionHandler]; [self presentViewController:fbController animated:YES completion:nil]; }

沒有留言:

張貼留言