我正在开发一款游戏,必须在我的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/