Question

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];
    }
}
Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top