Xcode7控件不显示&UIWebView不加载http请求

  • ViewController中控件不显示
  • 此处取消勾选Use Auto Layout并选择IPhone不然控件不会显示

QQ20160411-0

  • 用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>

QQ20160411-1

 

示例:

@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......")
    }

 

效果:

QQ20160411-2

发表评论

电子邮件地址不会被公开。 必填项已用*标注