我有一个名为 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*****`
}];
}];
}
最佳答案
尝试调用 _loginWebViewController
上的 dismiss 方法,而不是调用 self
[_loginWebViewController dismissViewControllerAnimated:YES completion: ^{
self.oauth1Controller = nil;
}];
关于ios - 从 ios 中的另一个 View 中关闭呈现的 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27620013/