【问题标题】:Twitter Integration in Cocos2d-iPhoneCocos2d-iPhone 中的 Twitter 集成
【发布时间】:2013-09-09 04:55:20
【问题描述】:

我正在开发一个游戏,我必须在我的 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];
}

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

【问题讨论】:

  • 是否进入条件块 if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) ?很可能是这种情况
  • 而可能是第二个原因是我假设 navController 属性位于 UINavigationController 上。所以你可以试试 [[[[myDelegate navController] viewcontrollers] objectAtIndex:0] presentViewController:fvc animated:YES completion:nil];
  • 由于 CCScene 的原因,它完全适用于 cocoa touch,但不适用于 cocos2d。而且你给定的也不起作用。我需要 cocos2d 的解决方案
  • 我已经通过添加视图控制器 [[[CCDirector sharedDirector] openGLView] addSubview:viewController.view]; [viewController presentViewController:fvc 动画:YES 完成:nil];

标签: ios objective-c ipad cocos2d-iphone


【解决方案1】:

CCDirector 是 iOS 中UIViewController 的子类。所以它可以用于呈现模态视图控制器。

[[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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-26
    • 2011-12-28
    • 1970-01-01
    • 1970-01-01
    • 2011-11-03
    相关资源
    最近更新 更多