Load local html into UIWebView using swift

前端 未结 13 2016
耶瑟儿~
耶瑟儿~ 2020-11-28 22:27

This one is driving me crazy early this morning. I want to load some local html into a web view:

class PrivacyController: UIViewController {

    @IBOutlet w         


        
相关标签:
13条回答
  • 2020-11-28 23:30

    To retrieve URLs for application resources, you should use URLForResource method of NSBundle class.

    Swift 2

    let url = NSBundle.mainBundle().URLForResource("privacy", withExtension:"html") 
    

    Swift 3

    let url = Bundle.main.url(forResource: "privacy", withExtension: "html")
    
    0 讨论(0)
提交回复
热议问题