iOS
SLComposeViewController
खोज…
Twitter, facebook, SinaWelbo और TencentWelbo के लिए SLComposeViewController
उद्देश्य सी
सबसे पहले XCode प्रोजेक्ट में Social Framework
जोड़ें।
आवश्यक ViewController के लिए #import "Social/Social.h"
वर्ग आयात करें
पाठ, छवि और लिंक के साथ ट्विटर
//- - To Share text on twitter - -
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
//Tweet
SLComposeViewController *twitterVC=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
//To send link together with text
[twitterVC addURL:[NSURL URLWithString:@"https://twitter.com/IbrahimH_ss_n"]];
//To add a photo to a link
[twitterVC addImage:[UIImage imageNamed:@"image"]];
//Sending link and Image with the tweet
[twitterVC setInitialText:text];
/* While adding link and images in a tweet the effective length of a tweet i.e.
the number of characters which can be entered by the user decreases.
The default maximum length of a tweet is 140 characters*/
[self presentViewController:twitterVC animated:YES completion:nil];
}
else
{//Shows alert if twitter is not signed in
UIAlertController *alertCont=[UIAlertController alertControllerWithTitle:@"SocialShare" message:@"You are not signed in to twitter."preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:alertCont animated:YES completion:nil];
UIAlertAction *okay=[UIAlertAction actionWithTitle:@"Okay" style:UIAlertActionStyleDefault handler:nil];
[alertCont addAction:okay];
}
}
टेक्स्ट, इमेज और लिंक के साथ फेसबुक
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
SLComposeViewController *fbVC=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[fbVC setInitialText:text];
//To send link together with text
[fbVC addURL:[NSURL URLWithString:@"https://twitter.com/IbrahimH_ss_n"]];
//To add a photo to a link
[fbVC addImage:[UIImage imageNamed:@"image"]];
[self presentViewController:fbVC animated:YES completion:nil];
}
else
{//Shows alert if twitter is not signed in
UIAlertController *alertCont=[UIAlertController alertControllerWithTitle:@"SocialShare" message:@"You are not signed in to twitter."preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:alertCont animated:YES completion:nil];
UIAlertAction *okay=[UIAlertAction actionWithTitle:@"Okay" style:UIAlertActionStyleDefault handler:nil];
[alertCont addAction:okay];
}
SinaWeibo
//- - SinaWeibo - -
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeSinaWeibo]){
SLComposeViewController *SinaWeiboVC=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeSinaWeibo];
[SinaWeiboVC setInitialText:text];
[self presentViewController:SinaWeiboVC animated:YES completion:nil];
}
else
{
UIAlertController *alertCont=[UIAlertController alertControllerWithTitle:@"SocialShare" message:@"You are not signed in to SinaWeibo."preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:alertCont animated:YES completion:nil];
UIAlertAction *okay=[UIAlertAction actionWithTitle:@"Okay" style:UIAlertActionStyleDefault handler:nil];
[alertCont addAction:okay];
}
टेनसेंट वीबो
//- -TencentWeibo text share
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTencentWeibo])
{
SLComposeViewController *tencentWeiboVC=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTencentWeibo];
[tencentWeibo setInitialText:text];
[self presentViewController:tencentWeibo animated:YES completion:nil];
}
else
{
UIAlertController *alertCont=[UIAlertController alertControllerWithTitle:@"SocialShare" message:@"You are not signed in to SinaWeibo."preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:alertCont animated:YES completion:nil];
UIAlertAction *okay=[UIAlertAction actionWithTitle:@"Okay" style:UIAlertActionStyleDefault handler:nil];
[alertCont addAction:okay];
}
Modified text is an extract of the original Stack Overflow Documentation
के तहत लाइसेंस प्राप्त है CC BY-SA 3.0
से संबद्ध नहीं है Stack Overflow