我有一个名为 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*****`
}];
}];
}
答案 0 :(得分:1)
而不是呼叫self
尝试在_loginWebViewController
[_loginWebViewController dismissViewControllerAnimated:YES completion: ^{
self.oauth1Controller = nil;
}];
答案 1 :(得分:1)
您可以更改:
[self dismissViewControllerAnimated:YES completion..]
到
[_loginWebViewController dismiss]
因为这个“self”正在呈现ViewController。