<span style="font-size:14px;">//
// ShareController.m
// xiaoyao
//
// Created by xiaoyao on 14/11/15.
// Copyright (c) 2014年 xiaoyao. All rights reserved.
//
#import "ShareController.h"
#import <ShareSDK/ShareSDK.h>
#import <AGCommon/AGCommon.h>
#import "ShareSDKHelper.h"
@interface ShareController ()
@end
@implementation ShareController
- (void)viewDidLoad {
[super viewDidLoad];
UIButton *shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
CGRect fm = CGRectMake(140, 200, 80, 50);
[shareButton setFrame:fm];
[shareButton setTitle:@"分享" forState:UIControlStateNormal];
[shareButton setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
shareButton.titleLabel.font = [UIFont systemFontOfSize:18];
[shareButton addTarget:self action:@selector(shareButtonClicked:)
forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:shareButton];
}
// 注册各平台的
- (void)shareToPlatform {
[ShareSDKHelper regeisterSharePlatformInAppDelegate];
}
- (void)shareButtonClicked:(UIButton *)shareButton {
id<ISSShareActionSheetItem> myItem = [ShareSDK shareActionSheetItemWithTitle:@"自定义功能"
icon:[UIImage imageNamed:@"sns_icon_30.png"]
clickHandler:^{
NSLog(@"执行你的分享代码!");
}];
NSArray *shareList1 = [ShareSDK customShareListWithType:
SHARE_TYPE_NUMBER(ShareTypeQQ),
SHARE_TYPE_NUMBER(ShareTypeWeixiSession),
SHARE_TYPE_NUMBER(ShareTypeWeixiTimeline),
myItem,
nil];
//定义容器
id<ISSContainer> container1 = [ShareSDK container];
[container1 setIPhoneContainerWithViewController:self];
// }
//定义分享内容
id<ISSContent> publishContent1 = nil;
NSString *contentString = @"This is a sample";
NSString *titleString = @"title";
NSString *urlString = @"http://www.ShareSDK.cn";
NSString *description = @"Sample";
publishContent1 = [ShareSDK content:contentString
defaultContent:@""
image:nil
title:titleString
url:urlString
description:description
mediaType:SSPublishContentMediaTypeText];
//定义分享设置
id<ISSShareOptions> shareOptions1 = [ShareSDK simpleShareOptionsWithTitle:@"分享内容" shareViewDelegate:nil];
[ShareSDK showShareActionSheet:container1
shareList:shareList1
content:publishContent1
statusBarTips:NO
authOptions:nil
shareOptions:shareOptions1
result:nil];
}
@end
</span>
用shareSDK自定义分享菜单项
最新推荐文章于 2020-10-21 16:16:27 发布