去ShareSdk官网下载demo,打开工程,找到SharingDemo Target子工程-->viewController-->simplyShare方法
- (void)simplyShare
{
/**
* 在简单分享中,只要设置共有分享参数即可分享到任意的社交平台
**/
__weak ViewController *theController = self;
[self showLoadingView:YES];
//创建分享参数
NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
NSArray* imageArray = @[[UIImage imageNamed:@"shareImg.png"],[UIImage imageNamed:@"shareImg.png"],[UIImage imageNamed:@"shareImg.png"]];
[shareParams SSDKSetupShareParamsByText:@"分享内容 http://www.mob.com"
images:imageArray
url:[NSURL URLWithString:@"http://www.mob.com"]
title:@"分享标题"
type:SSDKContentTypeAuto];
// [shareParams SSDKEnableUseClientShare];
//美拍需要传相册地址
// ALAssetsLibrary *assetsLibrary = [[ALAssetsLibrary alloc] init];
// NSString *path = [[NSBundle mainBundle] pathForResource:@"cat" ofType:@"mp4"];
// [assetsLibrary writeVideoAtPathToSavedPhotosAlbum:[NSURL URLWithString:path]
// completionBlock:^(NSURL *assetURL, NSError *error) {
// NSLog(@"%@",assetURL);
//
// [shareParams SSDKSetupMeiPaiParamsByUrl:assetURL type:SSDKContentTypeAuto];
//进行分享
[ShareSDK share:SSDKPlatformTypeTwitter
parameters:shareParams
onStateChanged:^(SSDKResponseState state, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error) {
[theController showLoadingView:NO];
[theController.tableView reloadData];
switch (state) {
case SSDKResponseStateSuccess:
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"分享成功"
message:nil
delegate:nil
cancelButtonTitle:@"确定"
otherButtonTitles:nil];
[alertView show];
break;
}
case SSDKResponseStateFail:
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"分享失败"
message:[NSString stringWithFormat:@"%@", error]
delegate:nil
cancelButtonTitle:@"确定"
otherButtonTitles:nil];
[alertView show];
break;
}
case SSDKResponseStateCancel:
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"分享已取消"
message:nil
delegate:nil
cancelButtonTitle:@"确定"
otherButtonTitles:nil];
[alertView show];
break;
}
default:
break;
}
}];
// }];
}
就此tweet分享搞定!