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