WooJin  Lee
WooJin Lee

Reputation: 61

Swift: Web View Doesn't Load Some Webpage

Here is my code:

import UIKit

class topLikeWebView : ViewController {

  @IBOutlet var topLikeWebView: UIWebView!

  override func viewDidLoad() {
    super.viewDidLoad()

    let url = NSURL(string: "http://www.lomort.co.kr/product/detail.html?product_no=252&cate_no=27&display_group=1")
    let requestObj = NSURLRequest(URL: url!)
    self.topLikeWebView.loadRequest(requestObj)
  }

}

However, this url doesn't load - http://www.lomort.co.kr/product/detail.html?product_no=252&cate_no=27&display_group=1. Other urls load fine, like apple.com or google.com.

What's wrong with this? I think the url is problem, not the code.
Then there is any distinction between the right url (can be loaded) or not?

Upvotes: 3

Views: 1885

Answers (1)

Rashwan L
Rashwan L

Reputation: 38833

Try to add this in your info.plist:

<key>NSAppTransportSecurity</key>
<dict>
  <!--Include to allow all connections (DANGER)-->
  <key>NSAllowsArbitraryLoads</key>
      <true/>
</dict>

If you manage to navigate with this, take a look at the NSAppTransportSecurity to add specific domains.

Upvotes: 2

Related Questions