Ios UIWebView未加载Google登录的所有页面
我正在构建一个带有Feedly身份验证的iOS应用程序。这个选择不是我做的,但我的任务是建造这个。因此,我在下面设置了Ios UIWebView未加载Google登录的所有页面,ios,authentication,uiviewcontroller,uiwebview,feedly,Ios,Authentication,Uiviewcontroller,Uiwebview,Feedly,我正在构建一个带有Feedly身份验证的iOS应用程序。这个选择不是我做的,但我的任务是建造这个。因此,我在下面设置了UIViewController,其中包含UIWebView。此webview加载Feedly身份验证页面。然而,在我按下谷歌之后。然后键入我的凭据,webview不会加载任何内容。即使多次单击“提交”,也不会发生任何事情。我做错了什么?它可能是localhost作为redirect\u uri LoginWebViewController.h #import <UIKit
UIViewController
,其中包含UIWebView
。此webview加载Feedly身份验证页面。然而,在我按下谷歌之后。然后键入我的凭据,webview不会加载任何内容。即使多次单击“提交”,也不会发生任何事情。我做错了什么?它可能是localhost
作为redirect\u uri
LoginWebViewController.h
#import <UIKit/UIKit.h>
@interface LoginWebViewController : UIViewController<UIWebViewDelegate>
@end
在输入我的凭据并按下谷歌的登录按钮后,它工作正常。它显示“feedly想访问页面…”。在设备上或使用其他google帐户进行尝试是的,但如果您单击“接受”以获取“feedly想要访问页面…”,则什么都不会发生…我认为您不是唯一一个看到以下内容的人:,这可能是他们在google身份验证中的问题。这实际上是我的问题。我不记得我已经贴了,虽然听起来很愚蠢。
#import "LoginWebViewController.h"
@interface LoginWebViewController ()
@end
@implementation LoginWebViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)viewWillAppear:(BOOL)animated {
UIToolbar *toolbar = [[UIToolbar alloc] init];
toolbar.frame = CGRectMake(0, 20, self.view.frame.size.width, 44);
toolbar.barTintColor = [UIColor redColor];
UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil];
#define UIColorFromRGB(rgbValue) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
// choose whatever width you need instead of 600
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(self.view.frame.size.width/2-40, 0, 80, 25)];
label.textAlignment = UITextAlignmentCenter;
label.backgroundColor = [UIColor clearColor];
label.shadowColor = UIColorFromRGB(0xe5e7eb);
label.shadowOffset = CGSizeMake(0, 1);
label.textColor = UIColorFromRGB(0x717880);
label.text = @"Log in";
label.font = [UIFont boldSystemFontOfSize:20.0];
UIBarButtonItem *toolBarTitle = [[UIBarButtonItem alloc] initWithCustomView:label];
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:@"Close"
style:UIBarButtonItemStyleDone target:self
action:@selector(dismissModalViewControllerAnimated:)];
NSArray *items = [[NSArray alloc] initWithObjects:doneButton, spacer, toolBarTitle, spacer, nil];
[toolbar setItems:items];
UIWebView *webview=[[UIWebView alloc]initWithFrame:CGRectMake(0, 24, self.view.frame.size.width, self.view.frame.size.height-24)];
webview.delegate = self;
NSString *url=@"https://sandbox.feedly.com/v3/auth/auth/?response_type=code&client_id=sandbox&redirect_uri=http://localhost&scope=https://cloud.feedly.com/subscriptions";
NSURL *nsurl=[NSURL URLWithString:url];
NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];
[webview loadRequest:nsrequest];
[self.view addSubview:webview];
[self.view addSubview:toolbar];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)webViewDidStartLoad:(UIWebView *)webView{
NSString *myRequestedUrl= [webView.request mainDocumentURL];
NSLog(@"Requested url: %@", myRequestedUrl);
}
- (void)webViewDidFinishLoad:(UIWebView *)webView{
NSString *myLoadedUrl = [webView.request mainDocumentURL];
NSLog(@"Loaded url: %@", myLoadedUrl);
}
@end