简体   繁体   English

如何打开OAuth弹出窗口(窗口层次结构)

[英]How to open OAuth popup (window hierarchy)

The implementation of this part should be pretty straightforward (but it isn't) 这部分的实现应该非常简单(但事实并非如此)

I implemented OAuthIODelegate into LoginViewController but the problem is when I run this code: 我将OAuthIODelegate实现到LoginViewController中,但问题是当我运行此代码时:

OAuthIOModal *oauthioModal = [[OAuthIOModal alloc] initWithKey:@"the_key" delegate:self];
[oauthioModal showWithProvider:@"facebook"];

Then I get this: 然后我明白了:

Warning: Attempt to present OAuthIOModal: 0x14ecc8e0 on MenuViewController: 0x14eb8d80 whose view is not in the window hierarchy! 警告:尝试在MenuViewController上显示OAuthIOModal:0x14ecc8e0:0x14eb8d80,其视图不在窗口层次结构中!

The problem with this is that I'm not even calling this on MenuViewController. 这个问题是我甚至没有在MenuViewController上调用它。

For testing purposes I'm calling LoginViewController from MenuViewController and then from login controller when I press a button I run the code above. 出于测试目的,我从MenuViewController调用LoginViewController,然后在按下按钮时从登录控制器调用上面的代码。

I've tried to find a solution but nothing this specific popped up. 我试图找到一个解决方案,但没有任何特定的弹出。

Help would be appreciated. 帮助将不胜感激。

tnx TNX

MenuViewController is set as your root view controller, but it isn't loaded (yet). MenuViewController被设置为根视图控制器,但尚未加载(尚未加载)。 I presume you're moving between views at this point. 我认为你现在正在观点之间移动。

Try putting your code in MenuViewController.m : viewDidLoad . 尝试将您的代码放在MenuViewController.m:viewDidLoad中。 You might need something to shift other business logic around this, but essentially you can't show a popup until the view has loaded. 您可能需要一些东西来改变其他业务逻辑,但实际上在视图加载之前您无法显示弹出窗口。

- (void)viewDidLoad {
    [super viewDidLoad];
    OAuthIOModal *oauthioModal = [[OAuthIOModal alloc] initWithKey:@"the_key" delegate:self];
    [oauthioModal showWithProvider:@"facebook"];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM