2

I am currently creating a SLComposeViewController using the following code...

- (IBAction)compose:(id)sender {
        if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
            SLComposeViewController *composeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
            [composeViewController setInitialText:@"Status from DummyCode.com"];
            [composeViewController setCompletionHandler:^(SLComposeViewControllerResult result) {
                if (result == SLComposeViewControllerResultDone) {
                    UIAlertView *success = [[UIAlertView alloc] initWithTitle:@"Success" message:@"Your status was successfully posted!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
                    [success show];
                }
                else {
                    [self dismissViewControllerAnimated:YES completion:nil];
                }
            }];
            [self presentViewController:composeViewController animated:YES completion:nil];
        } else {
            UIAlertView *error = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Error" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [error show];
        }
    }

I have an idea that I want to implement into my app. I want to keep "- DummyCode.com/social-media-app" on to the end of every tweet. I understand that it is probably not possible to lock this text or put it in at the end when the user presses "Send". If there is a workaround for one of these ideas please let me know.

But I have an idea that seems more possible, is it possible for me to move the cursor from the end of that text to the beginning so a user is more likely to leave that text on there.

Shown in the screenshots below. The first one is how it is now and the second is how I want it to be when I implement this little idea.

enter image description here

enter image description here

Is this even possible? Thanks!

-Henry

Dummy Code
  • 1,858
  • 4
  • 19
  • 38
  • This actually is possible when SLServiceTypeTwitter is enabled (not for Facebook). I've detailed an explanation here: [Prevent users from modifying part of the text in SLComposeViewController](http://stackoverflow.com/questions/13477970/prevent-users-from-modifying-part-of-the-text-in-slcomposeviewcontroller) – Mick MacCallum Jun 26 '13 at 17:50

1 Answers1

0

Have you simply considered appending the text once the user has typed their tweet? As in:

     NSString *initialText = @"Status from DummyCode.com";
     initialText = [initialText stringByAppendingString:@"DummyCode.com/social-media"];
     [composeViewController setInitialText:initialText];

You may want to check for the length of the tweet less the length of the string that you are tacking on, i.e. 140 - 25.

Tim L
  • 170
  • 6
  • Not sure what you mean by this... – Dummy Code Jun 24 '13 at 17:44
  • What I am suggesting is that you not add the "- DummyCode.com/social-media" until the tweet's contents are determined and the send button is pressed. That additional content is appended at that time. – Tim L Jun 25 '13 at 01:35
  • good idea, however I don't think you can jump in there and append it before the tweet is sent... – Dummy Code Jun 25 '13 at 03:48
  • That's how I do it. Maybe I am not understanding your question... – Tim L Jun 25 '13 at 03:52