我正在尝试使用 UIActivityViewController 实现共享功能。使用 Swift 5、Xcode 11.2.1、ios 13.2。
我使用了 UITableViewController 并在行的单击中调用了 share() 方法,如下所示:
class SettingsTableViewController: UITableViewController {
var tableData = ["Share with friends"]
// MARK: - Table view methods
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return tableData.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "settingsCell", for: indexPath)
let row = indexPath.row
cell.textLabel?.text = tableData[row]
return cell …Run Code Online (Sandbox Code Playgroud)