3 Star 0 Fork 0

Gitee 极速下载/gpactivityviewcontroller

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/gpinigin/GPActivityViewController
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

GPActivityViewController

Alternative to UIActivityViewController

iOS7 and later

Supported activities

  • Facebook
  • Twitter
  • Vkontakte
  • Odnoklassniki
  • Mail
  • Messages
  • Copy
  • Camera Roll
  • Maps
  • Safari

Requirements

  • Xcode 6.3+
  • Deployment Target iOS7.0+
  • ARC

Note: 2.0.2 — latest version with iOS5 support

Features

  • Landscape support
  • Pagination
  • Custom activities
  • Activity customization
  • ActivityViewController completion handler

Further work

  • Drop-in replacement for UIActivityViewController(use same activity)
  • iOS7 look and fill
  • Universal message composer

Installation

The recommended way is to use CocoaPods package manager.

To install using CocoaPods open your Podfile and add:

pod 'GPActivityViewController', :git => 'https://github.com/gpinigin/GPActivityViewController.git'

Social networks integration

For social networks listed below should be set application callback, for more info see chapter "Application callback".

Facebook (2.0.x Only)

  • Set up FacebookAppID property in your info.plist file, i.e. FacebookAppID = 12345678
  • Set up URL scheme for facebook redirect: fbFacebookAppID , where FacebookAppID - Facebook application ID

Odnoklassniki

  • Set up properties OdnoklassnikiAppID, OdnoklassnikiSecretKey, OdnoklassnikiAppKey in your info.plist file.
  • Set up URL scheme for redirect: okOdnoklassnikiAppID , where OdnoklassnikiAppID - Odnoklassniki application ID

Vkontakte

  • Set up VKontakteAppID property in your info.plist file

Usage

Activity controller

    // DO NOT forget to  setup application IDs in info.plist. For more info see README.md
    GPFacebookActivity *facebookActivity = [GPFacebookActivity new];
    GPTwitterActivity *twitterActivity = [GPTwitterActivity new];
    GPCopyActivity *copyActivity = [GPCopyActivity new];
    GPMailActivity *mailActivity = [GPMailActivity new];
    GPMessageActivity *messageActivity = [GPMessageActivity new];
    GPOKActivity *okActivity = [GPOKActivity new];
    GPVKActivity *vkActivity = [GPVKActivity new];
    
    NSArray *activities = @[mailActivity, messageActivity, facebookActivity, twitterActivity,
                            vkActivity, okActivity, copyActivity];
    GPActivityViewController *controller = [[GPActivityViewController alloc] initWithactivities:activities];

    controller.userInfo = @{@"text":@"Message to pass to activities",
                            @"url":[NSURL URLWithString:@"https://github.com/gpinigin"]};
    
    
    [controller presentFromBarButton:sender animated:YES];

Application callbacks

To complete authentication you should register url-schemes and add application callbacks in application delegate:

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {
    // For iOS 5.X only
    if ([FBSession.activeSession handleOpenURL:url]) {
        return YES;
    }

    if ([[OdnoklassnikiMgr sharedInstance] handleOpenURL:url]) {
        return YES;
    }

    if ([[VkontakteMgr sharedInstance] handleOpenURL:url]) {
        return YES;
    }

    return NO;
}

Subclassing notes

// Call it when activity is finished
- (void)activityFinished:(BOOL)completed;

// Should returns string that unique identifies your activity
- (NSString *)activityType;

// Override to implement your activity behavior
- (void)performActivity;

Note for iOS5.0: if autoorientation behavior of your controller isn't match to one of GPActivityViewController you MUST subclass GPActivityViewController to override autorotation behavior or present controller modally

Custom activities

You also can make your custom activity using block approach:

   GPActivity *myActivity = [customActivity:@"MACustomActivity" actionHandler:^(GPActivity *activity, NSDictionary *userInfo) {
        // Your code here
        //    ...
        
        // Activity is finished successfully
        [activity activityFinished:YES];
   }];
   
   myActivity.image = [UIImage imageNamed:@"myCustom"];
   myActivity.title = @"MyCustom";

You can also specify predefined acitivityInfo:

   NSURL *url = [NSURL URLWithString:@"google.com"];
   activity.userInfo = @{@"text":@"My custom activity",
                         @"url":url};

Credits

Partially based on REActivityViewController

Copyright (c) 2013 Gleb Pinigin (https://github.com/gpinigin) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

GPActivityViewController 是 UIActivityViewController 的替代品,兼容 iOS 5.0 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Objective-C
1
https://gitee.com/mirrors/gpactivityviewcontroller.git
git@gitee.com:mirrors/gpactivityviewcontroller.git
mirrors
gpactivityviewcontroller
gpactivityviewcontroller
master

搜索帮助