2

I want to post on twitter wall but don't want that user can edit message being posted.

So there is two possibility to do this

1) Either i can make TWTweetComposeViewController text field non editable.

2) Post without POP by TWTweetComposeViewController.

Please suggest me how to do out of above to options or any other ideas are most wel-come.

Thanks in Advance for any kind of Suggetions....

vikiiii
  • 9,246
  • 9
  • 49
  • 68
Nilesh Kikani
  • 2,628
  • 21
  • 37
  • Looks like this is exactly what you want: http://stackoverflow.com/questions/9423447/ios-5-twitter-framework-tweeting-without-user-input-and-confirmation-modal-vie – rosslebeau Mar 30 '12 at 11:41
  • In case you plan on integrating TwitterKit by Twitter to perform the tweets via your custom twitter app then this might help you. http://stackoverflow.com/a/28602749/1740354 – Vijay Tholpadi Feb 19 '15 at 09:39

2 Answers2

3

I modified your function "findSubViewofTwitter" in order to not sending the tweet without waiting the user to press send. My function simply makes non editable the UITextView .

- (void) findSubViewofTwitter:(UIView*)theView
{
    for (UIView * subview in theView.subviews)
    {
        if ([subview isKindOfClass:[UITextView class]])
        {
            UITextView *textView = (UITextView *)subview;
            textView.editable = NO;
            return;
        }
        [self findSubViewofTwitter:subview];
    }
}
marcomandy
  • 41
  • 4
3

i have done this by following code...

-(void)postToTwittert:(NSString *)stringtoPost
{    
    Class TWTweetComposeViewControllerClass = NSClassFromString(@"TWTweetComposeViewController");

    if (TWTweetComposeViewControllerClass != nil) {
        if([TWTweetComposeViewControllerClass respondsToSelector:@selector(canSendTweet)]) {
            TWTweetComposeViewController *twitter = [[TWTweetComposeViewController alloc] init];

            [twitter setInitialText:stringtoPost];

            [twitter addImage:[UIImage imageNamed:@"apple.jpg"]];
            [twitter addURL:[NSURL URLWithString:@"http://www.erwinzwart.com"]];
            [self findSubViewofTwitter:twitter.view];
            [self presentViewController:twitter animated:YES completion:nil];

            twitter.completionHandler = ^(TWTweetComposeViewControllerResult res) {

                if(res == TWTweetComposeViewControllerResultDone)
                {
                    [self completeGameStep:@"glueper2012"];                    

                }
                else if(res == TWTweetComposeViewControllerResultCancelled)
                {

                    UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Canceled" message:@"Your Tweet was not posted" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];

                    [alertView show];

                }

                [self dismissModalViewControllerAnimated:YES];

            };
        }
    } 
}

by finding button and firing event

    - (void) findSubViewofTwitter:(UIView*)theView
{
    for (UIView * subview in theView.subviews)
    {
        //NSLog(@">>>>>>>>>>>>>>>>>> :%@", subview);
        if ([subview isKindOfClass:[UIButton class]])
        {
            UIButton *btn = (UIButton *)subview;
            //NSLog(@">>>>>>>>>>>>>> is kind of class :%@", btn.titleLabel.text);
            if([btn.titleLabel.text isEqualToString:@"Send"])
            {
                [btn sendActionsForControlEvents:UIControlEventTouchUpInside];
            }
        }
        [self findSubViewofTwitter:subview];
    }
}
Muhammad Umar
  • 11,391
  • 21
  • 91
  • 193
Nilesh Kikani
  • 2,628
  • 21
  • 37