- ViewController中控件不显示
- 此处取消勾选Use Auto Layout并选择IPhone不然控件不会显示
- 用UIWebView不能请求到Http:
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app‘s Info.plist file.
- 因为苹果将原http协议改成了https协议,使用 TLS1.2 SSL加密请求数据。
- 在info.plist 加入key
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
示例:
@IBOutlet weak var wv:UIWebView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. print("URL Loading....") wv.loadRequest(NSURLRequest(URL: NSURL(string:"http://www.rancho.site")!)) print("URL loaded......") }
效果: