iOS 新增微信分享

2021-06-28 12:14:14 字數 3197 閱讀 7823

1、將sdk檔案中包含的libwechatsdk.a,wxapi.h, wxapiobject.h三個檔案新增到你所建的工程中。

2、選擇你的工程設定項,選中「targets」一欄,在「info」標籤欄的「url type「新增「url scheme」為你所註冊的應用程式id

寫了個工具類,在需要分享的時候直接呼叫就可以了(只寫了基本的,分享的時候定製介面啥的自己在這上面自由發揮吧!)

//先引入:#import"sharetoolviewcontroller.h"並加上**:

nsstring *title=@"pocket league story";

nsstring *detailinfo=@"一款非常不錯的物理益智遊戲,《拯救橘子》益智cover or突然來了的追捧。";

sharetoolviewcontroller *sharetoolviewcontroller = [[sharetoolviewcontroller alloc]

initwithnibname:@"sharetoolviewcontroller" bundle:nil];

sharetoolviewcontroller.delegate = self;

[self addchildviewcontroller:sharetoolviewcontroller];

[sharetoolviewcontroller initwhithtitle:title detailinfo:detailinfo image:nil imageurl:imageurl];

[self.view addsubview:sharetoolviewcontroller.view];

下面是這個類的具體內容:

//  sharetoolviewcontroller.h

#import typedef enum sharetooltype;

@protocol sharetoolviewcontrollerdelegate @end

@inte***ce sharetoolviewcontroller : uiviewcontroller

@property (nonatomic, retain)nsstring *sharetitle;

@property (nonatomic, retain)nsstring *detailinfo;

@property (nonatomic, retain)uiimage *shareimage;

@property (nonatomic, retain)nsstring *shareimageurl;

@property (nonatomic, assign)iddelegate;

- (void)initwhithtitle:(nsstring *)title detailinfo:(nsstring*)detailinfo

image:(uiimage *)image imageurl:(nsstring *)imageurl;

@end

//  sharetoolviewcontroller.m

#import "sharetoolviewcontroller.h"

#import "wxapi.h"

@inte***ce sharetoolviewcontroller ()

@end

@implementation sharetoolviewcontroller

@synthesize sharetitle = _sharetitle;

@synthesize detailinfo = _detailinfo;

@synthesize shareimage = _shareimage;

@synthesize shareimageurl = _shareimageurl;

- (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil

return self;

}- (void)viewdidload

#pragma mark - 分享

- (void)initwhithtitle:(nsstring *)title detailinfo:(nsstring*)info

image:(uiimage *)image imageurl:(nsstring *)imageurl

#pragma mark - uiactionsheet delegate

- (void)actionsheet:(uiactionsheet *)actionsheet clickedbuttonatindex:(nsinteger)buttonindex

}- (void)shareinformationwithtype:(sharetooltype)sharetooltype

case ksharetool_weixincirclefriends:

default:

break;

}}- (uiimage *)thumbimagewithimage:(uiimage *)scimg limitsize:(cgsize)limitsize

cgsize thumbsize;

if (scimg.size.width / scimg.size.height > limitsize.width / limitsize.height)

else

uigraphicsbeginimagecontext(thumbsize);

[scimg drawinrect:(cgrect)];

uiimage *thumbimg = uigraphicsgetimagefromcurrentimagecontext();

uigraphicsendimagecontext();

return thumbimg;

}- (void)sharehasdone

- (void)didreceivememorywarning

@end

IOS微信分享

ios開發工具包,解壓後得到 libwechatsdk.a wxapi.h wxapiobject.h 三個檔案。將這3個檔案拖到你的工程裡。然後 選擇你的工程設定項,選中 targets 一欄,在 info 標籤欄的 url type 新增 url scheme 為你所註冊的應用程式id。如圖然後...

iOS微信分享開發

m檔案 void rightbuttonclick uibutton abutton pragma mark actionsheet delegate void actionsheet uiactionsheet actionsheet clickedbuttonatindex nsinteger ...

ionic 微信分享之IOS版

作者在安裝方法中提到 add wechat lib to your project.don t forget to add the url type 由於對ios的配置環境不太了解,查了資料以後才知道,我們需要做的,如下 2 找到你的專案中字尾名為plist的檔案 可能具體的檔名會因專案不一樣 在下...