Can't load my web view with an http URL

不想你离开。 提交于 2019-12-10 19:34:19

问题


I have a problem in loading in my web view This is my code:

NSString *urlString = @"https://www.google.com.eg";

//    NSString *urlString = @"http://fatima.ibtdi.work";

NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
[_fatimaView loadRequest:urlRequest];}

It works on Google but doesn't work on the another link.


回答1:


Looks like you need to add some App Transport Security Settings to your Info plist try this

Any HTTP loading in a web view will require adding the domain to these settings.




回答2:


Add this to your plist

<key>NSAppTransportSecurity</key>
 <dict>
      <key>NSAllowsArbitraryLoads</key>
     <true/>
 </dict>



回答3:


You have to add

<key>NSAppTransportSecurity</key>
 <dict>
      <key>NSAllowsArbitraryLoads</key>
     <true/>
 </dict>

in your info.plist because your link "http://fatima.ibtdi.work" is not secured by SSL, so you have to add NSAppTransportSecurity in your info.plist file. IOS manage the link if the link is secured with SSL certificates else it block transportation from device to web.

Hope this helps you.



来源:https://stackoverflow.com/questions/44285901/cant-load-my-web-view-with-an-http-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!