Note that there are some explanatory texts on larger screens.

plurals
  1. POIOS: Facebook integration - Sharing current url of UIwebview
    primarykey
    data
    text
    <p>So i'm in the process of making a news reader app. Its source is a RSS feed, the user can click the stories that are presented in a tableview. This then opens the stories in a web view. I have a share feature setup for Facebook and Twitter, however I need this to automatically add the current url of the webview to the users post. Any help for a novice would be greatly appreciated! </p> <p>This is the code in my .m </p> <pre><code>- (IBAction)social:(id)sender { UIActionSheet *share = [[UIActionSheet alloc] initWithTitle:@"Pass on the news!" delegate:self cancelButtonTitle:@"OK" destructiveButtonTitle:nil otherButtonTitles:@"Post to Twitter", @"Post to Facebook", nil]; //You must show the action sheet for the user to see it. [share showInView:self.view]; } (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { //Each button title we gave to our action sheet is given a tag starting with 0. if (actionSheet.tag == 0) { //Check Twitter accessibility and at least one account is setup. if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) { SLComposeViewController *tweetSheet =[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; //This is setting the initial text for our share card. [tweetSheet setInitialText:@"Check out this article I found using the 'Pass' iPhone app: "]; //Brings up the little share card with the test we have pre defind. [self presentViewController:tweetSheet animated:YES completion:nil]; } else { //This alreat tells the user that they can't use built in socal interegration and why they can't. UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sorry" message:@"You can't send a tweet right now, make sure you have at least one Twitter account setup and your device is using iOS6 or above!." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alertView show]; } } else if (actionSheet.tag == 1) { //Check Facebook accessibility and at least one account is setup. if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) { SLComposeViewController *facebookSheet =[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; //This is setting the initial text for our share card. [facebookSheet setInitialText:@"Check out this article I found using the 'Pass' iPhone app:"]; //Brings up the little share card with the test we have pre defind. [self presentViewController:facebookSheet animated:YES completion:nil]; } else { //This alreat tells the user that they can't use built in socal interegration and why they can't. UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sorry" message:@"You can't post a Facebook post right now, make sure you have at least one Facebook account setup and your device is using iOS6 or above!." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alertView show]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload