简体   繁体   English

Cocos2d-iPhone中的Twitter集成

[英]Twitter Integration in Cocos2d-iPhone

I am developing a game in which i have to post scores on my Facebook and twitter a/c. 我正在开发一个游戏,我必须在我的Facebook和Twitter上发布分数a / c。

I have written this code but it not working. 我写了这段代码,但它没有用。 It's neither giving any error nor any popup for posting something . 它既没有给出任何错误也没有发布任何弹出窗口。

  - (void) SLComposeViewControllerButtonPressed: (id) sender{

 if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{

    AppDelegate * myDelegate = (((AppDelegate*) [UIApplication sharedApplication].delegate));

    NSString *string = [NSString stringWithFormat:@"Just scored %d. ", 10];

    SLComposeViewController*fvc = [SLComposeViewController
                                   composeViewControllerForServiceType:SLServiceTypeTwitter];
    [fvc setInitialText:string];
     [[myDelegate navController]  presentViewController:fvc animated:YES completion:nil];
}

Please give me valid solution of this problem. 请给我这个问题的有效解决方案。

CCDirector is a subclass of UIViewController in iOS. CCDirector是iOS中UIViewController的子类。 So it can be used for presenting modal viewControllers. 因此它可以用于呈现模态viewControllers。

[[CCDirector sharedDirector] presentViewController:fvc animated:YES completion:nil];

Update: Here is a DOC 更新: 这是DOC

  #ifdef __CC_PLATFORM_IOS
  #define CC_VIEWCONTROLLER UIViewController
  #elif defined(__CC_PLATFORM_MAC)
  #define CC_VIEWCONTROLLER NSObject
  #endif

  @interface CCDirector : CC_VIEWCONTROLLER

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM