我正在 SFSafariViewController
中打开一个 pdf 文件。现在我想从 SFSafariViewController
打印这个 PDF。
但是 Safari View Controller 的分享按钮没有打印选项。
请告诉我如何向 SFSafariViewController
添加打印功能。
您可以自定义事件。
extension ViewController: SFSafariViewControllerDelegate {
func safariViewController(_ controller: SFSafariViewController, activityItemsFor URL: URL, title: String?) -> [UIActivity] {
let acitivity = CustomActivity()
return [acitivity]
}
func printURL(url: URL) {
}
}
CustomActivity.swift
import Foundation
import UIKit
class CustomActivity: UIActivity {
override class var activityCategory: UIActivityCategory {
return .action
}
override var activityType: UIActivityType? {
return UIActivityType.print
}
override var activityTitle: String? {
return "rint"
}
override var activityImage: UIImage? {
return nil
}
override func canPerform(withActivityItems activityItems: [Any]) -> Bool {
return true
}
override func perform() {
// do something here
}
}
关于ios - 如何打印 SFSafariViewController 完整网页?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51147814/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |