zoukankan      html  css  js  c++  java
  • 微信分享

    首先要在微信开放平台申请 AppID(我第一天晚上申请的,第二天中午就通过了),接着导入 SDK,也就是3个 .h 和一个 .a 文件,详情见这里

    如果你是 copy 在自建 group 里面,

    1.需要在 Build Phases - Link Binary With Libraries 里面 .a 文件

    2.在 Copy Bundle Resources add .h 文件

    3.在 Bulid Settings - Library Search Paths "+" sdk 路径

    如果 copy 在自带 group 里面,则不需要,已经自动配置好

    AppDelegate.h ,import "WXApi.h" 和 遵守协议

    复制代码
    #import <UIKit/UIKit.h>
    #import "WXApi.h"
    
    @interface AppDelegate : UIResponder <UIApplicationDelegate,WXApiDelegate>
    
    @property (strong, nonatomic) UIWindow *window;
    
    @end
    复制代码

    AppDelegate.m

    复制代码
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        //申请的 AppID
        [WXApi registerApp:@"wxxxxx"];
        return YES;
    }
    //重写 handleOpenURL
    -(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{
        return [WXApi handleOpenURL:url delegate:self];
    }
    //重写 openURL
    -(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options{
        return [WXApi handleOpenURL:url delegate:self];
    }
    复制代码

    在你需要引用的类里面

    复制代码
    #import "ViewController.h"
    #import "WXApi.h"
    
    @interface ViewController ()
    @property (nonatomic,strong)UIButton *button;
    @end
    
    @implementation ViewController
    static NSString *KLinkURL = @"http://www.iqiyi.com/a_19rrhbkfv1.html?vfm=2008_aldbd";
    static NSString *KLinkTitle = @"史上最帅男人";
    static NSString *KLinkDescription = @"妈呀,谁都别拦我,我要嫁给他!!!!!!!!";
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        [self.view addSubview:self.button];
    }
    
    -(void)Click{
    
        //创建发送对象实例
        SendMessageToWXReq *sendReq = [[SendMessageToWXReq alloc] init];
        sendReq.bText = NO;//不使用文本信息
        sendReq.scene = 0;//0 = 好友列表 1 = 朋友圈 2 = 收藏
        
        //创建分享内容对象
        WXMediaMessage *urlMessage = [WXMediaMessage message];
        urlMessage.title = KLinkTitle;//分享标题
        urlMessage.description = KLinkDescription;//分享描述
     
        [urlMessage setThumbImage:[UIImage imageNamed:@"sb2.jpg"]];//分享图片,使用SDK的setThumbImage方法可压缩图片大小,图片大小不能超过 32 KB
        
        //创建多媒体对象
        WXWebpageObject *webObj = [WXWebpageObject object];
        webObj.webpageUrl = KLinkURL;//分享链接
        
        //完成发送对象实例
        urlMessage.mediaObject = webObj;
        sendReq.message = urlMessage;
        
        //发送分享信息
        [WXApi sendReq:sendReq];
    }
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
    }
    
    -(UIButton *)button{
        if (!_button) {
            _button = [[UIButton alloc]init];
            _button.frame = CGRectMake(100, 100, 100, 100);
            _button.backgroundColor = [UIColor redColor];
            [_button addTarget:self action:@selector(Click) forControlEvents:UIControlEventTouchUpInside];
        }
        return _button;
    }
  • 相关阅读:
    Oracle PL/SQL 概述
    Oracle 客户端 使用 expdp/impdp 示例 说明
    Oracle Expdp/Impdp 进行数据迁移的 几点注意事项
    Oracle PL/SQL 概述
    Oracle TIMED_STATISTICS 参数 说明
    Oracle Alerts 与 Metrics(警告与度量)说明
    Oracle OFA(Optimal Flexible Architecture) 说明
    Oracle OFA(Optimal Flexible Architecture) 说明
    Oracle dbca Exception in thread “main” 解决方法
    Oracle Resumable Space Allocation 特性 说明
  • 原文地址:https://www.cnblogs.com/cdp-snail/p/5519714.html
Copyright © 2011-2022 走看看