ios - Twitter在Cocos2d-iPhone中的集成

标签 ios objective-c ipad cocos2d-iphone

我正在开发一款游戏,必须在我的Facebook和Twitter A / C上发布分数。

我已经编写了这段代码,但是没有用。它既不会发出任何错误,也不会弹出任何东西。

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

请给我这个问题的有效解决方案。

最佳答案

CCDirector是iOS中UIViewController的子类。因此它可以用于呈现模式viewControllers。

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

更新:Here is a DOC
  #ifdef __CC_PLATFORM_IOS
  #define CC_VIEWCONTROLLER UIViewController
  #elif defined(__CC_PLATFORM_MAC)
  #define CC_VIEWCONTROLLER NSObject
  #endif

  @interface CCDirector : CC_VIEWCONTROLLER

关于ios - Twitter在Cocos2d-iPhone中的集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18691687/

相关文章:

ios - 如何将文件添加到主包的/Library/Sounds 目录?

xcode - iOS本地化不一致

ios - 从属性建立核心数据关系的最快方法是什么?

iphone - 调用 referenceSizeForFooterInSection 而不调用 reloadData

iphone - 在不重复代码的情况下执行初始化的最佳方法?

iphone - iOS 和 Google+ API

ios - 在日期选择器 IOS 中设置特定日期

ios - iOS团队开发中如何管理共享资源?

ios - subview 添加到导航栏 ios

iphone - 工具栏中的 Safari 风格 UIPopoverController