Ios5 我想通过tweetcomposeviewcontroller在没有弹出对话框的情况下发送tweet

Ios5 我想通过tweetcomposeviewcontroller在没有弹出对话框的情况下发送tweet,ios5,twitter,Ios5,Twitter,我想在推特墙上发布,但不想让用户编辑正在发布的消息 因此,有两种可能做到这一点 1) 我可以使tweetcomposeviewcontroller文本字段不可编辑 2) tweetcomposeviewcontroller发布无弹出消息 请建议我如何做以上的选择或任何其他想法都是最受欢迎的 提前感谢您提出的任何建议 我已通过以下代码完成此操作 -(void)postToTwittert:(NSString *)stringtoPost { Class TWTweetCompose

我想在推特墙上发布,但不想让用户编辑正在发布的消息

因此,有两种可能做到这一点

1) 我可以使tweetcomposeviewcontroller文本字段不可编辑

2) tweetcomposeviewcontroller发布无弹出消息

请建议我如何做以上的选择或任何其他想法都是最受欢迎的


提前感谢您提出的任何建议

我已通过以下代码完成此操作

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

            };
        }
    } 
}
通过查找按钮和触发事件

    - (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];
    }
}
我修改了你的函数“FindSubviewOfWitter”,以便在不等待用户按send键的情况下不发送推文。我的函数只是使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];
    }
}

看起来这正是您想要的:如果您计划通过Twitter集成TwitterKit,通过自定义Twitter应用程序执行推文,那么这可能会对您有所帮助。