UIWebview 不会显示 Https (iPhone)

发布于 2024-11-29 03:57:37 字数 935 浏览 0 评论 0原文

所以我写了一个 UIWebView 但当我尝试加载 https 页面时它不会加载...这是我的 WebView 的 .m 页面。

 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
 self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
 if (self) {
 // Custom initialization.
 }
 return self;
 }
 */


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://psportal.hbuhsd.org/ResetPassword.aspx"]]];
    webView.scalesPageToFit = YES;

    //Navigation Name:
    self.title = @"facebook";


    [super viewDidLoad];
}

-(void)webViewDidStartLoad:(UIWebView *)webView {
    [activityIndicator startAnimating];
    activityIndicator.hidden = NO;
}

-(void)webViewDidFinishLoad:(UIWebView *)webView {
    [activityIndicator stopAnimating];
    activityIndicator.hidden = YES;
}

So i wrote up a UIWebView but when i try to load an https page it wont load... here is my .m page for the WebView.

 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
 self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
 if (self) {
 // Custom initialization.
 }
 return self;
 }
 */


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://psportal.hbuhsd.org/ResetPassword.aspx"]]];
    webView.scalesPageToFit = YES;

    //Navigation Name:
    self.title = @"facebook";


    [super viewDidLoad];
}

-(void)webViewDidStartLoad:(UIWebView *)webView {
    [activityIndicator startAnimating];
    activityIndicator.hidden = NO;
}

-(void)webViewDidFinishLoad:(UIWebView *)webView {
    [activityIndicator stopAnimating];
    activityIndicator.hidden = YES;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

趁微风不噪 2024-12-06 03:57:37

第 1 步:确保您的 webView 已连接到您的 xib?

第2步:如果您尝试使用 xib 调用 viewController
覆盖 init 方法

 -(id)init{
   return [self initWithNibName:@"YourNibFileName" bundle:nil]
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = @"facebook";
    }
    return self;
}

并仅使用 init 方法初始化您的类
例如 :

YourViewController *_YVC = [[YourViewController alloc]init]autorelease];

加载视图

- (void)viewDidLoad {
    NSString* _urlString = @"https://psportal.hbuhsd.org/ResetPassword.aspx";
    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:_urlString]]];
    //webView.scalesPageToFit = YES;
    [super viewDidLoad];
}

并实现所有必需的 webView 委托方法,特别是 didFailLoadWithError它告诉您 Web 视图是否无法加载内容

Step1 : Make sure you webView is connected to your xib?

Step2 : If you are trying to call your viewController with xib
override the init method

 -(id)init{
   return [self initWithNibName:@"YourNibFileName" bundle:nil]
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = @"facebook";
    }
    return self;
}

And initialize your class with just init method
for example :

YourViewController *_YVC = [[YourViewController alloc]init]autorelease];

and after loading the view

- (void)viewDidLoad {
    NSString* _urlString = @"https://psportal.hbuhsd.org/ResetPassword.aspx";
    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:_urlString]]];
    //webView.scalesPageToFit = YES;
    [super viewDidLoad];
}

and implement all the required webView delegate method specially didFailLoadWithError (which tells you if a web view failed to load content)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文