GithubHelp home page GithubHelp logo

tsnumidc / tssharehelper Goto Github PK

View Code? Open in Web Editor NEW
99.0 7.0 16.0 2.02 MB

iOS分享,实现跳过选择界面多图分享,当然也可以不跳过.封装的是系统原生

License: Other

Objective-C 83.75% Ruby 16.25%

tssharehelper's Introduction

TSShareHelper  提醒一下各位,由于iOS11不支持,所以跳过选择页面不行了(目前判断了版本先用原生分享界面,让用户手动选微信吧)

功能 :iOS系统分享功能实现不经过选择,直接进入或者选择. 新增视频,文件的分享 判断了版本,做了回调处理.

  • 微信(前三个ios11之前支持直接弹出页面)
  • qq
  • 新浪
  • 原生选择界面 (ios11自动选择该type,请注意代码)

注意 : 其中传入的items包含UIImage或者NSURL的数组

/**
分享方法

@param type 分享类型
@param controller 展示的控制器
@param items 所有的分享对象 可以包括的类型是<UIimage NSURL>两种类型
@param completion 分享的回调 YES:成功 NO:失败
@return 返回分享结果 如果是No表示没有安装,请自行处理.
*/
+ (BOOL)shareWithType:(TSShareHelperShareType)type
        andController:(UIViewController *)controller
             andItems:(NSArray *)items
        andCompletion:(TSShareHelperCompleteHandler)completion;

效果图

具体实现

  • 调用系统的分享选择界面其实就是UIActivityViewController

    其中第一个参数穿入分享的对象(图片,url,string啥的)    第二个参数是可以穿入自定义UIActivity的,也就是选择界面的视图模型.

        UIActivityViewController * activityCtl = [[UIActivityViewController alloc]initWithActivityItems:items applicationActivities:nil];
        [controller presentViewController:activityCtl animated:YES completion:nil];
  • 跳过选择直接进入系统的分享主要是下面的代码,如果有其他类型分享,可以使用官方给的类型,也可以根据最下面的注释里的类型进行选择.
    SLComposeViewController *composeVC = [SLComposeViewController composeViewControllerForServiceType:serviceType];
    [composeVC addImage:(UIImage *)obj];
    [controller presentViewController:composeVC animated:YES completion:nil];

tssharehelper's People

Contributors

tsnumidc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

tssharehelper's Issues

iOS11下不可用

iOS11下,用SLComposeViewController分享到微信和QQ没效果,SLComposeViewController根本出不来,控制台打印:

2017-09-26 13:32:44.689141+0800 ShareMorePicToWX[14387:5256590] [core] SLComposeViewController initWithServiceType: com.tencent.xin.sharetimeline
2017-09-26 13:32:44.689293+0800 ShareMorePicToWX[14387:5256590] [core] SLComposeViewController initWithServiceType got extension (null) for identifier com.tencent.xin.sharetimeline
2017-09-26 13:32:44.689348+0800 ShareMorePicToWX[14387:5256590] [core] SLComposeViewController initWithExtension: (null) requestedServiceType: (null)
2017-09-26 13:32:44.690192+0800 ShareMorePicToWX[14387:5256590] [core] addImage start
2017-09-26 13:32:44.690247+0800 ShareMorePicToWX[14387:5256590] [core] addImage start
2017-09-26 13:32:44.690289+0800 ShareMorePicToWX[14387:5256590] [core] addImage start
2017-09-26 13:32:44.690329+0800 ShareMorePicToWX[14387:5256590] [core] addImage start
2017-09-26 13:32:44.690369+0800 ShareMorePicToWX[14387:5256590] [core] addImage start
2017-09-26 13:32:44.699862+0800 ShareMorePicToWX[14387:5256590] [core] viewWillAppear
2017-09-26 13:32:44.705108+0800 ShareMorePicToWX[14387:5256590] [core] viewDidAppear
2017-09-26 13:32:44.706422+0800 ShareMorePicToWX[14387:5256590] [core] ViewDidAppear, but remote VC failed, dismissing
2017-09-26 13:32:44.706860+0800 ShareMorePicToWX[14387:5256590] [core] Sheet not being presented, calling premature completion
2017-09-26 13:32:44.706905+0800 ShareMorePicToWX[14387:5256590] [core] SLComposeViewController completeWithResult: 0
2017-09-26 13:32:44.706978+0800 ShareMorePicToWX[14387:5256590] 点击了取消
2017-09-26 13:32:44.707063+0800 ShareMorePicToWX[14387:5256590] [core] SLComposeViewController automatically dismissing itself
2017-09-26 13:32:44.711762+0800 ShareMorePicToWX[14387:5256590] [core] SLComposeViewController dealloc <SLComposeViewController: 0x157d35d30>

用UIActivityViewController选微信或者QQ也不行,控制台打印:

2017-09-26 13:22:27.622056+0800 ShareMorePicToWX[14100:5244368] [core] SLComposeViewController initWithExtension: <NSExtension: 0x1c01768c0> {id = com.tencent.xin.sharetimeline} requestedServiceType: (null)
2017-09-26 13:22:27.625187+0800 ShareMorePicToWX[14100:5244368] [core] SLComposeViewController addExtensionItem: <NSExtensionItem: 0x1c0016610> - userInfo: {
NSExtensionItemAttachmentsKey = (
"<NSItemProvider: 0x1c00acd20> {types = (\n "public.image"\n)}",
"<NSItemProvider: 0x1c00ac9c0> {types = (\n "public.image"\n)}",
"<NSItemProvider: 0x1c00a8e20> {types = (\n "public.image"\n)}"
);
}
2017-09-26 13:22:28.166303+0800 ShareMorePicToWX[14100:5244368] [core] viewWillAppear
2017-09-26 13:22:28.166416+0800 ShareMorePicToWX[14100:5244368] [core] SLComposeViewController including 1 explicit NSExtensionItems
2017-09-26 13:22:28.166471+0800 ShareMorePicToWX[14100:5244368] [core] SLComposeViewController about to instantiate remote view controller with array of 1 NSExtensionItems
2017-09-26 13:22:28.168405+0800 ShareMorePicToWX[14100:5244368] [core] viewDidAppear
2017-09-26 13:22:28.433143+0800 ShareMorePicToWX[14100:5244368] [core] SLComposeViewController finished instantiate remote view controller (null) error Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.tencent.xin.sharetimeline.viewservice was interrupted, but the message was sent over an additional proxy and therefore this proxy has become invalid." UserInfo={NSDebugDescription=The connection to service named com.tencent.xin.sharetimeline.viewservice was interrupted, but the message was sent over an additional proxy and therefore this proxy has become invalid.} extension request identifier (null)
2017-09-26 13:22:28.433213+0800 ShareMorePicToWX[14100:5244368] [core] HOST: Failed to load remote view controller with error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.tencent.xin.sharetimeline.viewservice was interrupted, but the message was sent over an additional proxy and therefore this proxy has become invalid." UserInfo={NSDebugDescription=The connection to service named com.tencent.xin.sharetimeline.viewservice was interrupted, but the message was sent over an additional proxy and therefore this proxy has become invalid.}
2017-09-26 13:22:28.441385+0800 ShareMorePicToWX[14100:5244368] [core] Sheet not being presented, calling premature completion
2017-09-26 13:22:28.441408+0800 ShareMorePicToWX[14100:5244368] [core] SLComposeViewController completeWithResult: 0
2017-09-26 13:22:28.442141+0800 ShareMorePicToWX[14100:5244368] [core] SLComposeViewController skipping explicit dismiss because isBeingDismissed is already 1
2017-09-26 13:22:28.442503+0800 ShareMorePicToWX[14100:5244368] [core] SLComposeViewController completeWithResult: 0
2017-09-26 13:22:28.442519+0800 ShareMorePicToWX[14100:5244368] [core] SLComposeViewController skipping explicit dismiss because isBeingDismissed is already 1
2017-09-26 13:22:28.443633+0800 ShareMorePicToWX[14100:5244368] [core] SLComposeViewController dealloc <SLComposeViewController: 0x1060439c0>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.