通过SafariViewController查询网站 Day22

今天作为使用SFSafariViewController作为载入画面

其实这个使用非常的简单

只有两个步骤:

  • import SafariServices
  • 将SafariViewController实例化并且给予其url参数
  • present SafariViewController

import SafariServices

import SafariServices

SafariViewController实例化并且给予其url参数

// 实例化SafariViewController
// url的给予 记得要在www前面加上https://
let safariVC = SafariViewController(url:URL(string:"https://www.google.com)!)

present SafariViewController

// 跑出SafariViewController
present(safariVC, animated:true, completion:nil)

就这样可以大功告成了

附上我比较完整的程序码

因为我是用Static Cell作为我的呈现,所以不用再numberOfRowsInSection设定一大堆

override func numberOfSections(in tableView: UITableView) -> Int {
        // #warning Incomplete implementation, return the number of sections
        return 1
    }

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning Incomplete implementation, return the number of rows
        return 5
    }

    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        switch indexPath.row {
        case 4:
            let SafariWebView = SFSafariViewController(url: URL(string: "https://www.google.com")!)
            present(SafariWebView, animated: true, completion: nil)
        
        default:
            break
        }
    }

成果展示:

https://i.imgur.com/3Aqhwto.gif


<<:  25. Redux 的用途 & 入门实作 (上)

>>:  【Day 11】- 再次创造 Ghost Process,这次找不到了吧哈哈(基於修改 PspCidTable 隐藏的 Rookit)

Day 14: DockerFile实作Node前後端 (下)

Node前端 今天来讲Vue前端的与postgres包入进docker,和後端编译後直接放入相比,前...

共享资料夹&硬碟管理总结

经过「安全」的硬碟部署,最後设置共享资料夹来「驱动」硬碟 确认unRaid Array启动後,转到 ...

#15- 滚起来!页面动态进度条(JS算网页长度)

进度条一般都是搭配文章使用, 主要是告诉使用者目前阅读到哪里~ 这是我自己非常喜欢的网页设计, 让你...

Day 30 - 开发流程(下) Web 开发流程 & 铁人赛心得

上一篇Day 29 - 开发流程(上) 瀑布式(Waterfall Model) & 敏捷式...