In our iOS software development we need to share some of the picture screens and documents and stuff. But it is possible to use other software, at which point we need to learn to share.
Let's give an example of sharing:
Look at the code
See APPDELEGATE.M file contents First
Inside the APPDELEGATE.M we need
[Wxapi registerapp:@ "WX252E7C172102F9CB" withdescription:@ "Share 1.0"];
Just to share.
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions {//Override point for customization after application launch. /*only by writing this sentence can we realize the sharing function in the specific place WX252E7C172102F9CB this project to the registered developer Account Share 1.0*/[Wxapi Registerapp:@"WX252E7C172102F9CB"Withdescription:@"Share 1.0"]; Self.window=[[UIWindow alloc] initwithframe:[[uiscreen mainscreen] bounds]; Viewcontroller* TEMPVC =[[Viewcontroller alloc] init]; Self.window.rootViewController=TEMPVC; [Self.window makekeyandvisible]; returnYES;}
Look at the controller again.
. h file
#import <UIKit/UIKit.h>@interface**wechatfriendsbtn; @end
. m file
#import "ViewController.h"#import "WXApi.h"@interfaceViewcontroller ()@end#defineKloadimage (name, type) [UIImage imagewithcontentsoffile:[[nsbundle Mainbundle] Pathforresource:name Oftype:type]#defineScreenWidth Self.view.frame.size.width#defineScreenHeight Self.view.frame.size.height@implementationViewcontroller- (void) viewdidload{[Super Viewdidload]; _WECHATFRIENDBTN=[UIButton Buttonwithtype:uibuttontypecustom]; _wechatfriendbtn.frame= CGRectMake (ScreenWidth/2- -, ScreenHeight/2- -, the, the); [_wechatfriendbtn Setshowstouchwhenhighlighted:yes]; [_wechatfriendbtn Setbackgroundimage:kloadimage (@"Btn_ Friends",@"PNG") Forstate:uicontrolstatenormal]; _wechatfriendbtn.enabled=YES; _wechatfriendbtn.tag=1; [_wechatfriendbtn addtarget:self Action: @selector (btnclicked:) forcontrolevents:uicontroleventtouchupinside]; [Self.view ADDSUBVIEW:_WECHATFRIENDBTN]; _WECHATFRIENDSBTN=[UIButton Buttonwithtype:uibuttontypecustom]; _wechatfriendsbtn.frame= CGRectMake (ScreenWidth/2+ +, ScreenHeight/2- -, the, the); [_wechatfriendsbtn Setshowstouchwhenhighlighted:yes]; [_wechatfriendsbtn Setbackgroundimage:kloadimage (@"Btn_ Circle of Friends",@"PNG") Forstate:uicontrolstatenormal]; _wechatfriendsbtn.tag=2; [_wechatfriendsbtn addtarget:self Action: @selector (btnclicked:) forcontrolevents:uicontroleventtouchupinside]; [Self.view ADDSUBVIEW:_WECHATFRIENDSBTN]; }-(void) btnclicked: (UIButton *) btn{Switch(Btn.tag) { Case 1: { //This kind of sharing is with the text and the picture share, belongs to the Web share, the attention sharing picture size cannot exceed 32k. Wxmediamessage *message =[Wxmediamessage message]; //share the title of the contentMessage.title =@"share the title"; //description of shared contentMessage.description =@"Share the introduction"; //share the picture[Message Setthumbimage:kloadimage (@"Share",@"PNG")]; //Share LinksWxwebpageobject *ext = [WxwebpageobjectObject]; Ext.webpageurl=@"www.sougou.com"; Message.mediaobject=ext; Sendmessagetowxreq* req =[[Sendmessagetowxreq alloc] init]; /*the type of message sent, including text messages and multimedia messages, both can only select one, cannot send both text and multimedia messages*/Req.btext=NO; Req.message=message; //This attribute means sharing to a friendReq.scene =wxscenesession; [Wxapi Sendreq:req]; //This kind of sharing is plain text information. //sendmessagetowxreq* req = [[Sendmessagetowxreq alloc] init]; //req.text = _linkstr; //req.btext = YES; //req.scene = wxscenesession; //[Wxapi sendreq:req]; } Break; Case 2: {wxmediamessage*message =[Wxmediamessage message]; Message.title=@"share the title"; Message.description=@"Share the introduction"; [Message Setthumbimage:kloadimage (@"Share",@"PNG")]; Wxwebpageobject*ext = [WxwebpageobjectObject]; Ext.webpageurl=@"www.baidu.com"; Message.mediaobject=ext; Sendmessagetowxreq* req =[[Sendmessagetowxreq alloc] init]; Req.btext=NO; Req.message=message; //This attribute means sharing to a friend CircleReq.scene =Wxscenetimeline; [Wxapi Sendreq:req]; //sendmessagetowxreq* req = [[Sendmessagetowxreq alloc] init]; //req.text = _linkstr; //req.btext = YES; //req.scene = wxscenetimeline; //[Wxapi sendreq:req]; } Break; }}- (void) didreceivememorywarning {[Super didreceivememorywarning]; //Dispose of any resources the can be recreated.}@end
Sharing of iOS development