2

我使用下面的代码目前正在创建一个SLComposeViewController ...的iOS SLComposeViewController“黑客”

- (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]; 
     } 
    } 

我有,我想落实到我的应用程序的想法。我想保留“ - DummyCode.com/social-media-app”到每个推文结束。我明白,当用户按下“发送”时,可能无法锁定该文本或将其放入最后。如果有其中一个想法的解决方法,请让我知道。

但是我有一个似乎更可能的,是有可能,我将光标从文本开始的端移动,因此用户更可能留下的文字上有一个想法。

显示在下面的截图中。第一个是现在的样子,第二个是我实现这个小想法时的样子。

enter image description here

enter image description here

这甚至可能吗?谢谢!

-Henry

+0

启用SLServiceTypeTwitter时,这实际上是可能的(不适用于Facebook)。我在这里详细的解释:防止用户在SLComposeViewController文本的修改部分(http://stackoverflow.com/questions/13477970/prevent-users-from-modifying-part-of-the-text-in -slcomposeviewcontroller) –

回答

0

你有没有简单地认为附加文本一旦用户输入他们的鸣叫?如:

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

您可能要检查的鸣叫字符串的少长度的长度,你是会附上,即140 - 25

+0

不知道你的意思是什么? –

+0

我的建议是,你不添加“ - DummyCode.com/social-media”,直到鸣叫的内容被确定和发送按钮被按下。该附加内容在当时被追加。 –

+0

好主意,但是我不认为你可以跳到那里并在发送推文之前追加它... –