//
// ViewController.m
// shareSDK分享
//
// Created by dc008 on 15/12/25.
// Copyright © 2015年 崔晓宇. All rights reserved.
//
#import "ViewController.h"
#import <ShareSDK/ShareSDK.h>
//#import <TencentOpenAPI/QQApiInterface.h>
//#import <TencentOpenAPI/TencentOAuth.h>
//#import "WXApi.h"
//#import "WeiboSDK.h"
//#import <RennSDK/RennSDK.h>
@interface ViewController ()
{
UIButton *_button;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self layoutUI];
}
- (void)layoutUI{
_button = [[UIButton alloc]initWithFrame:CGRectMake(0, 600, 375, 40)];
_button.backgroundColor = [UIColor grayColor];
[_button setTitle:@"分享" forState:UIControlStateNormal];
[_button addTarget:self action:@selector(shared:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:_button];
}
- (void)shared : (UIButton *)sender {
NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"ShareSDK" ofType:@"png"];
//构造分享内容
id<ISSContent> publishContent = [ShareSDK content:@"分享内容"
defaultContent:@"测试一下"
image:[ShareSDK imageWithPath:imagePath]
title:@"ShareSDK"
url:@"http://www.mob.com"
description:@"这是一条测试信息"
mediaType:SSPublishContentMediaTypeNews];
//创建弹出菜单容器
id<ISSContainer> container = [ShareSDK container];
[container setIPadContainerWithView:sender arrowDirect:UIPopoverArrowDirectionUp];
//弹出分享菜单
[ShareSDK showShareActionSheet:container
shareList:nil
content:publishContent
statusBarTips:YES
authOptions:nil
shareOptions:nil
result:^(ShareType type, SSResponseState state, id<ISSPlatformShareInfo> statusInfo, id<ICMErrorInfo> error, BOOL end) {
if (state == SSResponseStateSuccess)
{
NSLog(@"分享成功");
}
else if (state == SSResponseStateFail)
{
NSLog(@"分享失败,错误码:%ld,错误描述:%@", [error errorCode], [error errorDescription]);
}
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end