ios - 从 ios 中的另一个 View 中关闭呈现的 View Controller

标签 ios objective-c xcode navigation presentmodalviewcontroller

我有一个名为 AViewController。它包含一个按钮,用于显示名为 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/

相关文章:

ios - 具有固定高度/宽度的自定大小的 UICollectionViewCell

iphone - 执行错误访问问题

ios - UITableViewController 中的 numberOfRowsInSection 部分值始终为 1

xcode - Swift Xcode6 beta6 正则表达式

ios - 由于未捕获的异常 'NSInvalidArgumentException' 而终止应用程序,原因 : 'Application tried to present a nil modal view controller on target

ios - 苹果应用程序评论 : Demo Account for Instagram?

ios - [Swift]如何将字符串分配给 UITextField?

ios - 限制UIButton标题文本框

ios - 如何隐藏 SpriteKit 游戏的状态栏?

ios - 无法在@interface或@protocol内声明变量,移动会导致其他地方崩溃