2014-09-24 89 views
1

我整合LinkedIn的API到我的应用程序使用下面的链接LinkedIn API获取问题为iOS

https://github.com/jeyben/IOSLinkedInAPI

第一次它的loggedIn具有相当不错的,当我被整合该API到我的应用程序。这起正从LinkedIn API类,如下问题及其从来没有打开LinkedIn loginview由于以下

- (void)showAuthorizationView:(LIALinkedInAuthorizationViewController *)authorizationViewController { 
    if (self.presentingViewController == nil) 
    self.presentingViewController = [[UIApplication sharedApplication] keyWindow].rootViewController; 
    UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:authorizationViewController]; 
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { 
    nc.modalPresentationStyle = UIModalPresentationFormSheet; 
    } 
    [self.presentingViewController presentViewController:nc animated:YES completion:nil]; 

} 

问题是

[self.presentingViewController presentViewController:nc animated:YES completion:nil]; 
错误后

误差

Warning: Attempt to present <UINavigationController: 0x787db610> on <myViewController: 0x78677de0> whose view is not in the window hierarchy!** 

其很奇怪,我检查了一些论坛的运行代码,建议在viewDidAppear,但在我的情况下,我不能在viewDidAppear运行这个,因为它不是我的自定义类。任何人都可以请任何人建议我如何避免这个问题?由于这个问题,当我点击LinkedIn登录按钮时,Loginview没有出现,我正在使用XCode6。提前致谢!

回答

2
[self.presentingViewController presentViewController:nc animated:YES completion:nil]; 

这就是说你正试图从presentsViewController中呈现你的nc。但这里的问题是你的presentingViewcontroller不在视图层次结构中(即在presentingViewcontroller中的实例既没有呈现也没有被推送(根本不可见))