Foreign third party sharing, including Facebook,twitter,instagram

Source: Internet
Author: User

1.facebook, Twitter, etc.

With the iphone's own sharing, first import social.framework, and then import

#import <Social/Social.h> End With the following code to complete the share:

Slcomposeviewcontroller *COMPOSEVC = [Slcomposeviewcontroller composeviewcontrollerforservicetype:sharedname];

BOOL success = [COMPOSEVC setinitialtext:self.sharedcontent];//share content

BOOL imagesuccess = [COMPOSEVC addimage:self.sharedimage];//share picture

Callback

Slcomposeviewcontrollercompletionhandler Myblock = ^ (Slcomposeviewcontrollerresult result) {

if (result = = slcomposeviewcontrollerresultcancelled) {

NSLog (@ "cancelled");

}else{

NSLog (@ "Post");

}

[Composevc Dismissviewcontrolleranimated:yes Completion:nil];

};

Composevc.completionhandler = Myblock;

if (Success && imagesuccess)

[Self PRESENTVIEWCONTROLLER:COMPOSEVC animated:yes completion:nil]; }
2.Instagram a little trouble, through the Uidocumentinteractioncontroller to complete the sharing, first of all, we must first determine whether the existence of Instagram, if there is a sharing of the operation. The code is as follows:

-(void) Instagramshare: (uiview*) view{

uiimage* image = [UIImage imagenamed:@ "csh.jpg"];//shared pictures

CGFloat cropval = (Image.size.height > image.size.width? image.size.width:image.size.height);

Cropval *= [Image scale];

CGRect croprect = (cgrect) {. Size.Height = Cropval,. size.width = Cropval};

Cgimageref imageref = Cgimagecreatewithimageinrect ([Image cgimage], croprect);

NSData *imagedata = uiimagejpegrepresentation ([uiimage imagewithcgimage:imageref], 1.0);

Cgimagerelease (IMAGEREF);

NSString *writepath = [Nstemporarydirectory () stringbyappendingpathcomponent:@ "Instagram.igo"];

if (![ ImageData Writetofile:writepath Atomically:yes]) {

Failure

NSLog (@ "image save failed to path%@", Writepath);

Return

} else {

Success.

}

Send it to Instagram.

Nsurl *fileurl = [Nsurl Fileurlwithpath:writepath];

Self.documentcontroller = [Uidocumentinteractioncontroller Interactioncontrollerwithurl:fileurl];

Self.documentController.delegate = self;

[Self.documentcontroller setuti:@ "Com.instagram.exclusivegram"];

[Self.documentcontroller setannotation:@{@ "instagramcaption": @ "My Love Dyl"}];

CGRect rect = CGRectMake (0, 0, 0, 0);

Uigraphicsbeginimagecontextwithoptions (View.bounds.size, View.opaque, 0.0);

[View.layer Renderincontext:uigraphicsgetcurrentcontext ()];

Uigraphicsendimagecontext ();

[Self.documentcontroller presentopeninmenufromrect:rect Inview:view Animated:yes];

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.