2015-07-11 54 views

回答

3

确保您UIWebView是具有UINavigationController视图控制器内。我怀疑你是以模态方式呈现登录屏幕(通过故事板或以编程方式) - 尝试将其推到导航堆栈上。

编辑:这是我的意思的代码,在QEFilesListViewController

GTMOAuth2ViewControllerTouch *authViewController = 
[[GTMOAuth2ViewControllerTouch alloc] initWithScope:kGTLAuthScopeDriveFile 
              clientID:kClientId 
             clientSecret:kClientSecret 
            keychainItemName:kKeychainItemName 
              delegate:self 
            finishedSelector:finishedSelector]; 
[self presentViewController:authViewController 
        animated:YES 
       completion:nil]; 

如果你改变了最后陈述

[self.navigationController pushViewController:authViewController animated:YES]; 

你会得到一个返回按钮:

enter image description here

我知道当你按下后退按钮时,它会再次自动显示登录画面。我想如果你想在你自己的应用中实现这一点,你可以采取适当的措施,以确保不会发生。

+0

我们只是使用Google SDK。不在UIWebView中显示。 参考网址:https://github.com/googledrive/ios-quickeditor –

2

试试波纹管代码。这个补丁解决了我的问题。

GTMOAuth2ViewControllerTouch *authViewController = [GTMOAuth2ViewControllerTouch controllerWithScope:kGTLAuthScopeDrive 
                            clientID:GoogleDriveClientID 
                           clientSecret:GoogleDriveClientSecret 
                          keychainItemName:GoogleDriveKeychainItemName 
                          completionHandler:authCompletionHandler]; 

     UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:authViewController]; 
     navigationController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 
     [rootController presentViewController:navigationController animated:YES completion:nil]; 

     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 
      UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Cancel", nil) 
                      style:UIBarButtonItemStylePlain 
                      target:self 
                      action:@selector(didCanceledAuthorization)]; 
      authViewController.navigationItem.rightBarButtonItem = nil; 
      authViewController.navigationItem.leftBarButtonItem = cancelButton; 
      authViewController.navigationItem.title = @"Google Drive"; 
     }); 
相关问题