我正在尝试在SFSafariVC的屏幕底部放置一个图像,它将有与设备交互的按钮。我已经添加了没有问题的SafariViewController,但我不知道如何添加图像,任何帮助或建议将非常感谢。
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print("row selected: \(filteredTable[indexPath.row])")
let selURL = URL(string: "https://www.google.com/")
let selSite = SFSafariViewController(url: selURL!)
present(selSite, animated: true, completion: nil)
selSite.delegate = self as? SFSafariViewControllerDelegate
}供参考的代码
发布于 2018-08-20 01:11:05
我不确定这个解决方案是不是你想要的,但在某些情况下,你不能访问视图控制器来添加视图,你可以将你的视图添加到关键窗口;
更新
guard let url = URL(string: "https://google.com/") else {
return //be safe
}
let svc = SFSafariViewController(url: url)
self.present(svc, animated: true, completion: nil)
let image = UIImage(named: "img")
let imgV = UIImageView(image: image)
imgV.frame = CGRect(x: 0, y: UIScreen.main.bounds.size.height - 30, width: UIScreen.main.bounds.size.width, height: 30)
UIApplication.shared.keyWindow?.addSubview(imgV)通过此代码,无需执行任何操作即可在safari视图上显示图像(已测试)
https://stackoverflow.com/questions/51919226
复制相似问题