从ios中的另一个视图中解除显示的视图控制器

时间:2014-12-23 12:04:35

标签: ios objective-c xcode navigation presentmodalviewcontroller

我有一个名为 A ViewController 。它包含一个按钮,用于显示名为LinkedInWebVC的新 ViewController 。 现在,我想从 A 中解雇LinkedInWebVC

我的代码如下:

-(IBAction)button_tap:(id)sender
{
_loginWebViewController = [[LinkedInWebVC alloc]initWithNibName:@"LinkedInWebVC" bundle:nil];

    [self presentViewController:_loginWebViewController
                       animated:YES
                     completion:^{
                         [self.oauth1Controller loginWithWebView:_loginWebViewController.webView completion:^(NSDictionary *oauthTokens, NSError *error) {
                             if (!error) {
                                 // Store your tokens for authenticating your later requests, consider storing the tokens in the Keychain
                                 self.oauthToken = oauthTokens[@"oauth_token"];
                                 self.oauthTokenSecret = oauthTokens[@"oauth_token_secret"];

                             }
                             else
                             {
                                 NSLog(@"Error authenticating: %@", error.localizedDescription);
                             }

                             [self dismissViewControllerAnimated:YES completion: ^{
                                 self.oauth1Controller = nil;
                             }]; `*****Problem is here, not dismiss LinkedInWebVC*****`
                         }];
                     }];

}

2 个答案:

答案 0 :(得分:1)

而不是呼叫self尝试在_loginWebViewController

上调用dismiss方法
 [_loginWebViewController dismissViewControllerAnimated:YES completion: ^{
                                 self.oauth1Controller = nil;
                             }];

答案 1 :(得分:1)

您可以更改:

[self dismissViewControllerAnimated:YES completion..]

[_loginWebViewController dismiss]

因为这个“self”正在呈现ViewController。

相关问题