2014-09-24 40 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中的實例既沒有呈現也沒有被推送(根本不可見))