【发布时间】: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