UIWebview wont Display Https (iPhone)

2019-07-25 13:49发布

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;
}

1条回答
孤傲高冷的网名
2楼-- · 2019-07-25 14:40

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)

查看更多
登录 后发表回答