1

i can't seem to get the SLComposeViewController to come from a button on a cocos2D layer. If you could see anything that would stop this working please tell. Any help would be appreciated: N.B. viewController is a UIViewController

-(void)sceneSelect
{
    NSString *message = [NSString stringWithFormat:@"Twitter Message"];

    NSString *serviceType = [NSString stringWithFormat:@"SLServiceTypeTwitter"];


    if ([SLComposeViewController isAvailableForServiceType:serviceType])
    {
        SLComposeViewController *tweetController = [SLComposeViewController composeViewControllerForServiceType:serviceType];
        [tweetController setInitialText:message];

        tweetController.completionHandler = ^(SLComposeViewControllerResult result){


            if (result == SLComposeViewControllerResultDone){
               //NSLog call
            }
            else if (result == SLComposeViewControllerResultCancelled){
               //NSLog call
            }

            [viewController dismissViewControllerAnimated: YES completion: nil];
        };

        [[[CCDirector sharedDirector]openGLView]addSubview:viewController.view];
        [viewController presentViewController:tweetController animated:YES completion:nil];
    }

    else
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Twitter" message:@"Twitter not working" delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];

        [alertView show];
    }
}
Guru
  • 21,652
  • 10
  • 63
  • 102
user2318726
  • 33
  • 1
  • 4

1 Answers1

0

Cocos2d 2.0 then use navigation controller in AppDelegate

    AppController *app = (AppController*) [[UIApplication sharedApplication] delegate];
    [[app navController] presentModalViewController:tweetController animated:YES];

HERE IS MY FULL TWITTER CODE: http://pastebin.com/hpRRJM1n

Guru
  • 21,652
  • 10
  • 63
  • 102
  • Thanks for the response. I tried that, it works well for UIActivityView but can't get it to work for SLComposeViewController, thats why I tried the above. I will keep trying and see what I can get otherwise I will run with the UIActivityView. Any other insights would be great. – user2318726 Apr 26 '13 at 02:32