我正在尝试删除我创建的facebook视图控制器。基本上,初始化视图控制器的showFBLoginView方法是App Delegate,并在GameOver层中调用。
-(void)showFBLoginView {
facebookViewController = [[FacebookViewController alloc] init];
self.facebookViewController = facebookViewController;
// Set loginUIViewController as root view controller
[[self window] setRootViewController:facebookViewController];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
[self.facebookViewController activateButton:@"Facebook Connect"];
.
.
.
}
facebookViewController.m类中的activateButton方法:
-(void)activateButton:(NSString*)buttonText {
CGSize screenSize = [[CCDirector sharedDirector] winSize];
fbConnectButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
fbConnectButton.frame = CGRectMake(screenSize.width/2 - 50*(screenSize.width/480) , screenSize.height/2, screenSize.width/4, screenSize.height/12);
[fbConnectButton setTitle:buttonText forState:UIControlStateNormal];
fbConnectButton.backgroundColor = [UIColor redColor];
[fbConnectButton setTitleColor:[UIColor brownColor] forState:UIControlStateNormal ];
[fbConnectButton addTarget:self action:@selector(callButtonTouched) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:fbConnectButton];
}
我尝试以下列方式删除faceboookViewController。这是在App Delegate中完成的。
[[self window] removeFromSuperview];
但它不起作用。删除视图控制器的正确方法是什么?
答案 0 :(得分:0)
faceboookViewController *fbViewController =
[self.storyboard instantiateViewControllerWithIdentifier:@"StoryboardID"];
[self dismissViewControllerAnimated:YES completion:nil];
StoryboardID是faceboookViewController的StoryboardID。 如果你出示,你可以解雇。