【问题标题】:I want to tweet without pop dialog by TWTweetComposeViewController我想通过 TWTweetComposeViewController 在没有弹出对话框的情况下发推文
【发布时间】:2012-04-14 00:58:55
【问题描述】:

我想在 Twitter 墙上发帖,但不希望该用户可以编辑正在发布的消息。

所以有两种可能这样做

1) 我可以让 TWTweetComposeViewController 文本字段不可编辑。

2) 通过 TWTweetComposeViewController 发布不带 POP 的帖子。

请建议我如何从上述选项或任何其他想法中脱颖而出。

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

【问题讨论】:

标签: ios5 twitter


【解决方案1】:

我已经通过以下代码做到了这一点...

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2012-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-15
      • 2018-11-23
      相关资源
      最近更新 更多