gpt4 book ai didi

ios - CCDirector 可能无法响应 presentviewcontroller :animation

转载 作者:行者123 更新时间:2023-11-29 12:41:45 25 4
gpt4 key购买 nike

我是 cocoa2d 的新手。我正在尝试在 View 中使用 presentViewController 进行 Facebook 共享。

代码如下:

-(void)shareFB:(NSString *)text
{
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {

SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

[controller setInitialText:text];

[[CCDirector sharedDirector]presentViewController:controller animated:YES completion:nil];
}
else
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Sorry!" message:@"Please add Facebook account in settings menu" delegate:Nil cancelButtonTitle:@"OK" otherButtonTitles:Nil, nil];
[alert show];
}
}

它发出警告:

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

即:CCDirector 可能不会响应“presentviewcontroller:animated:completion:”

最佳答案

您好,我编辑了您的代码并稍加修改并粘贴在下方。一切正常

SLComposeViewController *faceBookPost = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

[faceBookPost setInitialText:@"I am playing game"];
[faceBookPost addURL:[NSURL URLWithString:@"http://www.yourlink.com"]];
[[CCDirector sharedDirector]presentViewController:faceBookPost animated:YES completion:nil];
faceBookPost.completionHandler = ^(SLComposeViewControllerResult result)
{
[[CCDirector sharedDirector] resume];
[[CCDirector sharedDirector] startAnimation];
[[CCDirector sharedDirector]dismissViewControllerAnimated:YES completion:nil];
};

否则按照这一步

像这样使用 uinavigationcontroller 在您的 AppController 中创建一个界面

@interface MyNavigationController : UINavigationController <CCDirectorDelegate>
@end

@interface AppController : NSObject <UIApplicationDelegate>
{
UIWindow *window_;
MyNavigationController *navController_;
CCDirectorIOS *director_;
}

在应用 Controller 的 didFinishLaunchingWithOptions 中设置导航 Controller

navController_ = [[MyNavigationController alloc] initWithRootViewController:director_];
navController_.navigationBarHidden = YES;
[director_ setDelegate:navController_];
// set the Navigation Controller as the root view controller
[window_ setRootViewController:navController_];

然后在你调用 SLComposeViewController 的类中呈现这样的 View

 AppController *app = (AppController*) [[UIApplication sharedApplication] delegate];
[[app navController] presentViewController:faceBookPost animated:YES completion:nil];

两种类型都可以正常工作

关于ios - CCDirector 可能无法响应 presentviewcontroller :animation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24710191/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com