2014-09-12 65 views
0

我想刪除我創建的Facebook視圖控制器。基本上,初始化視圖控制器的showFBLoginView方法是App Delegate,並在GameOver圖層中調用。我怎樣才能刪除一個Facebook登錄視圖控制器?

-(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中完成的。

但它不工作。什麼是刪除視圖控制器的正確方法?

回答

0
faceboookViewController *fbViewController = 
[self.storyboard instantiateViewControllerWithIdentifier:@"StoryboardID"]; 
[self dismissViewControllerAnimated:YES completion:nil]; 

StoryboardID是faceboookViewController的StoryboardID。 如果您出示,您可以解僱。

相關問題